max wrote:
look at using entity-name in Hibernate3.
With entity-name you can map the same class to multiple table (the thing that now differs is the entity-name instead of classname)
I need to to split data into diffent tables of a legacy-system.
Depending on the id of an object the mapping should be selecetd.
e.g obj1 with id = 1000 has another mapping than obj2 with id= 2000
<class
...
entity-name ="1000"
...
</class>
<class
...
entity-name ="2000"
</class>
This will result in an error of the JDBC-DRIVER when a SELECT-STATEMENT is issued by hibernate, because the value of entity-name (eg. 1000 or 2000) is used to create an alias for the table name.
Is there any way that the value of the <entity-name> tag is not bounded by the JDBC-Driver?
Hibernate: select 1000x_.id, 1000x_.column1 as column2_0_, 1000x_.column2 as column3_0_ from test.t1 1000x_ where 1000x_.id=?
com.mchange.v2.c3p0.impl.NewPooledConnection@3020ad invalidated by Exception: org.postgresql.util.PSQLException: ERROR: syntax error at or near "x_"
at org.postgresql.util.PSQLException.parseServerError(PSQLException.java:139)
A workaround is to use "n1000" and "n2000" instead of "1000" and "2000". But that´s not sufficient for my problem.
In fact the mapping according to the id of an object is not the whole problem.The reason why I´m trying to omit the JDBC-restrictions is, that I´ve also other properties eg. listId, listSelectionId. Depending on the values of these properties the mapping has to be selected.
e.g.
list1Id = 1 and list1SelectionId =1 => mapping1
list1Id = 1 and list1SelectionId =2 => mapping2
...
And depending on the combination of the values of other properties some values have to be modified.
e.g.
list2Id = 1 and list2SelectionId = 1 => Update .... SET x = y *10
list2Id = 1 and list2SelectionId = 2 => Update .... SET x = y *100
list2Id = 1 and list2SelectionId = 3 => Update .... SET x = y *1000
So entity-name does not all I need.
Any suggestions?