Hello All,
I am migrating an existing datamodel and trying to map hibernate onto to schema. I have seen post whihch are related to this issue, but have not been given a reason why this can not be done. Can anyone help?
here is the encountered problem....
I have a relationship the is logically a subclass relationship (ie: user->agent user). But the schema defines a primary key column for each table and obviously a forign key column in the "agent user" to relate it back to the user table. So the agent user table has a Primary key to uniquely identify it (to other tables) AND a Foriegn Key to the users. I am aware that this is probaly not a clever design (especially for my needs) but it is in existance and I must try to use it.
Using XDoclet, my generated mapping files fails to pick up my primary key in the Agent User class and instead defaults the primary key to the user tables foriegn key (because of the sub-classe relationship). When I run my unit tests, the agent can not be persisted due to a not null constraint on the primary key column in the database. The generated SQL has ignored my tables primaray key and does not insert a value into it.
Hibernate (or xdoclet) has essentially ignored my declaration of a primary key definition for the Agent user object and used the parents class primary key. The mapping file has no record of my primary key?
It is not disirable to redifine the scema because we need to be backward compatible.
I am wondering why this is not supported in hiberrnate? or is it?
Hibernate version:
2.17
Mapping documents:
N/A
Xdoclet:
Here is my xdoclet declaration placed above my relavent setter for my primary key field...
/**
* @hibernate.id
* generator-class="sequence"
* type="long"
* column="AGENTID"
* @hibernate.generator-param
* name="sequence"
* value="MCS_AGENT_SEQ"
*
*/
Here is my xdoclet for the class declaration...
@hibernate.joined-subclass table="MCS_AGENT"
* @hibernate.joined-subclass-key column="PAYMENTUSERID"
and my code is something like....
public class Agent extends User .
I *DO NOT* want the joined-subclass-key column to be the primary key column in my new mapping, but this seems to be imnpossible
Full stack trace of any exception that occurs:
N/A
Name and version of the database you are using:
Oracle 9
The generated SQL (show_sql=true):
n/A
Debug level Hibernate log excerpt:
n/a
|