DataPortal.Fetch failed (Could not compile the mapping document: (unknown)) - fluent-nhibernate

I added a new field in SQL server database. and implement all related properties in the application which is developed in NHibernate.
[Property(Name = "IntervalUnit", Column = "IntervalUnit", NotNull = false)]
private long _IntervalUnit = 0;
I don't have any hbm or XML file for properties.
but still I am getting this issue
DataPortal.Fetch failed (Could not compile the mapping document: (unknown))
What do I need to do?

Related

Core Data + CloudKit Migration: Cannot create or modify field [...] in record [...] in production schema

I use NSPersistentCloudKitContainer to sync Core Data with Cloud Kit. To prepare for a new migration, I have created a new model version of the xcdatamodel and marked it as "current". I created a new entity and added a relationship from another entity. Nothing spectacular and suitable for a lightweight migration I thought.
Let's name this new entity: EntityNew
This is my code to initialize the NSPersistentCloudKitContainer:
lazy var persistentContainer: NSPersistentContainer = {
let container = NSPersistentCloudKitContainer(name: "MyContainerName")
container.loadPersistentStores(completionHandler: { _, error in
guard let error = error as NSError? else { return }
fatalError("###\(#function): Failed to load persistent stores:\(error)")
})
container.viewContext.automaticallyMergesChangesFromParent = true
return container
}()
shouldMigrateStoreAutomatically and shouldInferMappingModelAutomatically are set to true by default.
Everything worked fine locally. No errors occurred during the migration.
The problems started when I created a new instance of EntityNew:
let newItem = EntityNew(context: context)
newItem = "..."
saveContext()
newItem was created locally without any problems, but the iCloud Sync stopped working from this moment. The following error appeared in the console:
"<CKRecordID: 0x283fb1460; recordName=2E2209A1-F9F6-4DF2-960D-2C31F764ED05, zoneID=com.apple.coredata.cloudkit.zone:__defaultOwner__>" = "<CKError 0x2830a5950: \"Batch Request Failed\" (22/2024); server message = \"Atomic failure\"; uuid = ADA626F4-160E-49FE-A0BD-2198E5FBD09A; container ID = \"iCloud.[MyContainerID]\">"
"<CKRecordID: 0x283fb1a00; recordName=3145C837-D80D-47E0-B944-DBC6576A9B0A, zoneID=com.apple.coredata.cloudkit.zone:__defaultOwner__>" = "<CKError 0x2830a4000: \"Invalid Arguments\" (12/2006); server message = \"Cannot create or modify field 'CD_[Fieldname in EntityNew]' in record 'CD_[OtherEntityName]' in production schema\"; uuid = ADA626F4-160E-49FE-A0BD-2198E5FBD09A; container ID = \"iCloud.[ContainerID]\">";
"Cannot create or modify field 'CD_[Fieldname in EntityNew]' in record 'CD_[OtherEntityName]' in production schema"
Cloud Kit tries to modify the field CD_[Fieldname in EntityNew] (which is correct) on the record CD_[OtherEntityName], which is not the entity I created above! So Core Data tries to modify the wrong entity! This behavior does not happen for all fields (approx. 5 out of 10). I checked the local sqlite file of my iPhone but the local tables seems correct. The phenomenon can be observed in both, the Development and the Production icloud-container-environment. If I start with an empty database (which already contains the new entity, so no migration is necessary) the synchronization works.
What did I miss? Any ideas?
Thank you!

Spring boot does not create tables from entities

When I try to save an entity for the first time, I got those errors. It is spring boot.
lifePolicyReconciliationReceivedRepository.save(lifePolicyReconciliationReceived);
this is repository.
I got those errors:
ARJUNA016129: Could not end XA resource com.ibm.db2.jcc.t4.a4#3275401a
com.ibm.db2.jcc.am.XaException: [jcc][t4][10401][12066][4.24.92] XA exception: XA_RBROLLBACK ERRORCODE=-4228, SQLSTATE=null
All fields are filled before this. Entity is this:
#Entity #Table(
schema = "CREAM" // i want to put in that schema // , // name = "D_RECONCILIATION_RECEIVED" // i sometimes give name, but with or without it, errors are taken
)
#Getter
#Setter
#NoArgsConstructor
public class LifePolicyReconciliationReceived extends Serializable {
/**
*
*/
private static final long serialVersionUID = 1L;
#Id
#GeneratedValue(strategy = GenerationType.AUTO)//i also did GenerationType.IDENTITY but still error
private Long id;
private Long applicationId;
#Temporal(TemporalType.DATE)
private Date receiveDate;
#Temporal(TemporalType.DATE)
private Date startDate;
#Temporal(TemporalType.DATE)
private Date endDate;
}
When i change to Id to .IDENTITY, it becomes:
Caused by: com.ibm.db2.jcc.am.SqlSyntaxErrorException: DB2 SQL Error: SQLCODE=-204, SQLSTATE=42704, SQLERRMC=CREAM.D_RECONCILIATION_RECEIVED, DRIVER=4.24.92
WHen i create manually by going to sql, there is no problem. It can save there but why do i have to do? Spring boot can do it and connect manytoone and other relationships.
Because according to here
DB2 SQL Error: SQLCODE=-204, SQLSTATE=42704
second error is for missing schema. Why doesnt it create itself?
This repository:
public interface LifePolicyReconciliationReceivedRepository extends JpaRepository<LifePolicyReconciliationReceived, Long> {
}
Normally, there was no properties file. Only yml for port. But i created and added this:
spring.jpa.hibernate.ddl-auto=update
And application java file, I added this:
#EntityScan(basePackages = {"com/xxx/xxx/dbmodel, "com.xxxx.xxx.dataaccess""})
#EnableConfigurationProperties
There are maven modules. I am using one of modules. So, I have to give entity path and other one is repository path.
But did not work.
Also, changed to this but still did not work:
spring.jpa.hibernate.ddl-auto=update
spring.datasource.url=jdbc:db2://192.168.xx.xx:60000/FF
spring.datasource.username=qqq
spring.datasource.password=fff
So, when application is starting, there is not the table created. I am checking logs. So after app starts, i try to save. When repository tries to save, it gets errors.
Method threw 'org.springframework.dao.InvalidDataAccessResourceUsageException' exception.

Connection String Issues With Entity Framework Context And Deleting

I have a simple find delete case:
var query = CompanyUsers
.Where ( cu => cu.eMail.Contains( "123#email.com") || cu.eMail.Contains( "456#email.com"))
ServicesEntities se = new ServicesEntities();
se.DeleteObject( query );
ServiceEntities is a EntityFramework 4.1 DLL. The only thing in the DLL is the EF model.
When I try to delete I get:
"ArgumentException: The specified named connection is either not found in the configuration, not intended to be used with the EntityClient provider, or not valid."
If I try adding the name of the connection string in the app.config file like this:
ServicesEntities se = new ServicesEntities("ServicesEntities");
I get: ArgumentException: Format of the initialization string does not conform to specification starting at index 0.
How can I use my EF model and perform deletes using the conext. Is it possible to pass through the connection string that LINQPad appears to be creating in the properties tab or at the minimum use the one from the app.config?

Pass a Guid to NHibernate's ISession.Get<T> method

I'm experiencing with NHibernate 3.1.0 (without Fluent yet) on an existing solution in VS2010. Our DB is MsSql 2008 (I'm using NHibernate.Dialect.MsSql2008Dialect in the cfg.xml file).
I have an ValidationActivity object which I'd like to get from the DB. It has an ActivityID column of type uniqueidentifier (in the DB) / Guid (in the business object).
I've been following Summer Of NHibernate's 1st session so my provider is:
public ValidationActivity GetActivityById(Guid activityGuid)
{
var sessionFactory = new configuration().Configure().BuildSessionFactory();
var session = sessionFactory.OpenSession();
return session.Get<ValidationActivity>(activityGuid);
}
My mapping uses the guid generator:
<id name="ActivityID" type="Guid">
<generator class ="guid"/>
</id>
To test that, I created a test that tries to get an activity with a known Guid (one that I've inserted manually) as follows:
NHibernateDataProvider provider = new NHibernateDataProvider();
Guid guid = new Guid("885f380d-c6e3-459e-8cff-10f96f26cc0a");
Activity testActivity = provider.GetActivityById(guid);
The exception thrown is 'Could not load entity' with the following SQL string:
SELECT validation0_.ActivityID as ActivityID0_0_, validation0_.ActivityName as Activity2_0_0_, validation0_.CreationDate as Creation3_0_0_, validation0_.Owner as Owner0_0_, validation0_.Project as Project0_0_, validation0_.Step as Step0_0_ FROM Activities validation0_ WHERE validation0_.ActivityID=?
It seems to me that the '?' at the end is wrong, but I don't know what am I doing wrong.
Please help.
Thanks.
Take a look at this post with a similar problem:
Mapping Error in NHibernate
Have you tried to run the query above replacing the ? with the actual guid in the database that this test is hitting? Are all the column/table names the same? Seems like it could be a mapping issue.

linq to sql generates an faulting connectionstring

Started working after some days off, and generated a new dbml file through vs 2008. then it sent an error:
Object reference not set to an instance of an object.
MyBase.New(Global.System.Configuration.ConfigurationManager.ConnectionStrings("C__USERS_JIMMY_DOCUMENTS_VISUAL_STUDIO_2008_WEBSITES_LUNCHGUIDEN_APP_DATA_LUNCHGU"& _
row 88:"IDEN_MDFConnectionString").ConnectionString, mappingSource)
its like the dbml generates an own connection string, but i have done this alot of times before without it happening?
the problems is when i put it up on a sharp server.. it obviously cant find the connectionstring. what to do so the connectionstring doesnt get generated wrong?
Use the datacontext constructor with the connectionstring in parameter so it will not look after the default one
Ex:
using(MyDbContext context = new MyDbContext(ConfigurationManager.ConnectionStrings["myConnection"].ConnectionString))
{
...
}
Could it be that while you added a new entity to the model that the appSettings have been generated? It seems that linq to sql is always storing the connectionstring of the entity that was previously added to the model.