mnimer / dphibernate

Automatically exported from code.google.com/p/dphibernate
0 stars 0 forks source link

Composite key issue #34

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Set up two tables (A and B) with a many-to-many relation between them
2. One of these tables (or both) must have a composite primary key (here A)
3. Try to lasy load the set of A from an entity B

What is the expected output? What do you see instead?
Instead of a set of A entity, for each call to the remote function
load(clazz=A.class, proxyKey=key) produce this kind of exception :
"org.hibernate.TypeMismatchException : Provided id of the wrong type
for class model.Ecoprocess. Expected: class model.EcoprocessId, got
class java.lang.Integer"

What version of the product are you using? On what operating system?
dpHibernate 1.0.17. Windows Vista 64.

Please provide any additional information below.

The problem seems to be in getPkIds from HibernateSerializer.java
Type t = persister.getKeyType();
PreparedStatement stmt =
((SessionImpl)session).connection().prepareStatement(sql);
if( t instanceof StringType ){
    stmt.setString(1, collection.getKey().toString());
}
else {
    stmt.setObject(1, new Integer(collection.getKey().toString()).intValue());
}

"t" is converted to an integer if it's not a String. What if it's an
composite key entity ?

Attached files : Category and Ecoprocess, my two concerned entities, and
the composite key EcoprocessId.

Original issue reported on code.google.com by CHe...@gmail.com on 31 Jul 2009 at 11:04

Attachments:

GoogleCodeExporter commented 9 years ago
Composite keys are not currently supported.

Original comment by martypit...@gtempaccount.com on 9 Jul 2010 at 3:11

GoogleCodeExporter commented 9 years ago
I've created issue 43 for discussion and tracking of the feature to add support 
for composite keys.

http://code.google.com/p/dphibernate/issues/detail?id=43

Original comment by martypit...@gtempaccount.com on 9 Jul 2010 at 3:13