Hi,
I made futher test on DomainObject and I get this problem.
With my db access class I try to create Patient. Patient has a string as primary key :
<ClassDescriptor ClassName="com.diagast.testdbmapping.Patient" TableName="PATIENT">
<PrimaryKeyDescriptor IsAutoIncremented="false">
<FieldDescriptor Id="PATIENT1" FieldName="_primaryKey" IsDeclaredInBaseClass="true" DbType="AnsiString" ColumnName="ID" Length="100" />
</PrimaryKeyDescriptor>
<FieldDescriptor Id="PATIENT2" FieldName="_name" PropertyName="Name" DbType="AnsiString" ColumnName="NAME" Length="60" />
<FieldDescriptor Id="PATIENT3" FieldName="_firstname" PropertyName="Firstname" DbType="AnsiString" ColumnName="FIRSTNAME" Length="60" />
<FieldDescriptor Id="PATIENT4" FieldName="_birthdate" PropertyName="Birthdate" DbType="DateTime" ColumnName="BIRTHDATE" />
</ClassDescriptor>
I use my dbaccess class like this :
// always return null because the object is never created.
Patient pat1 = (Patient)dbaccess.FindObjectInDBWithPrimaryKey<Patient>("name_pat1" + "first_pat1");
//create the patient. No created in db ???
pat1 = new Patient("name_pat1", "first_pat1", new DateTime());
pat1 = (Patient)dbaccess.CreateObjectInDB<Patient>(pat1);
//get patient 1
// return the patient even if it's not created in db. I think It come from the cache.
pat1 = (Patient)dbaccess.FindObjectInDBWithPrimaryKey<Patient>("name_pat1" + "first_pat1");
The CreateObjectInDB never create the patient. I have other mapped object like Demand that have int primarykey and it works. But for the patient they are never created. The FindObjectInDBWithPrimaryKey find the patient but not in the DB.
Have you any idea ?
Regards
Philippe Delrieu
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi Richard,
the problem can be seen in the same project as the other post (I resend you the project).
At the beginning of createDBObject method (ObjectFactory.cs line 102),
I create a patient and store it in db.
After the creation, I look the table with a query tool, no patient is created.
After I query the database, the patient is found but it isn't in db.
regards
Philippe Delrieu
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi,
I made futher test on DomainObject and I get this problem.
With my db access class I try to create Patient. Patient has a string as primary key :
<ClassDescriptor ClassName="com.diagast.testdbmapping.Patient" TableName="PATIENT">
<PrimaryKeyDescriptor IsAutoIncremented="false">
<FieldDescriptor Id="PATIENT1" FieldName="_primaryKey" IsDeclaredInBaseClass="true" DbType="AnsiString" ColumnName="ID" Length="100" />
</PrimaryKeyDescriptor>
<FieldDescriptor Id="PATIENT2" FieldName="_name" PropertyName="Name" DbType="AnsiString" ColumnName="NAME" Length="60" />
<FieldDescriptor Id="PATIENT3" FieldName="_firstname" PropertyName="Firstname" DbType="AnsiString" ColumnName="FIRSTNAME" Length="60" />
<FieldDescriptor Id="PATIENT4" FieldName="_birthdate" PropertyName="Birthdate" DbType="DateTime" ColumnName="BIRTHDATE" />
</ClassDescriptor>
I use my dbaccess class like this :
// always return null because the object is never created.
Patient pat1 = (Patient)dbaccess.FindObjectInDBWithPrimaryKey<Patient>("name_pat1" + "first_pat1");
//create the patient. No created in db ???
pat1 = new Patient("name_pat1", "first_pat1", new DateTime());
pat1 = (Patient)dbaccess.CreateObjectInDB<Patient>(pat1);
//get patient 1
// return the patient even if it's not created in db. I think It come from the cache.
pat1 = (Patient)dbaccess.FindObjectInDBWithPrimaryKey<Patient>("name_pat1" + "first_pat1");
The CreateObjectInDB never create the patient. I have other mapped object like Demand that have int primarykey and it works. But for the patient they are never created. The FindObjectInDBWithPrimaryKey find the patient but not in the DB.
Have you any idea ?
Regards
Philippe Delrieu
Hi Philippe,
Let me write some unit tests that involve a string primary key and I'll get back to you. All of our current unit tests utilize an int primary key...
Hmm... You might as well test w/ GUID's as a primary key as well.
Hi Richard,
I don't understand your remarq.
Did you find anything ?
regards
Philippe
No I haven't found anything yet. If you send me your test project on this one also, it will make it easier for me to reproduce... Thanks Philippe.
Hi Richard,
the problem can be seen in the same project as the other post (I resend you the project).
At the beginning of createDBObject method (ObjectFactory.cs line 102),
I create a patient and store it in db.
After the creation, I look the table with a query tool, no patient is created.
After I query the database, the patient is found but it isn't in db.
regards
Philippe Delrieu