hi all
i'm trying to enable my hibernate / java application for cross platform usage, it should run with oracle 10g as well as with microsoft sql server 2008
my env:
- windows server 2008 E SP2
- java jdk 1.5.0_18
- jboss 4.3.0_GA coming with hibernate 3.2.4
- microsoft sqljdbc 2.0 driver
- microsoft sql server 2008 E
to do this i set up id generator-class to "native" for all hibernate classes to use sequences on oracle and identity on sql server. this worx fine so far but not for composite elements on sql server (while running fine with oracle 10g).
i'm having a "RoutingTable" with "Route" as composite element, configured as follows:
Code:
/**
* @hibernate.collection-id generator-class = "native" type =
* "java.lang.Long" column = "ID"
* @hibernate.composite-element class = "com.rixxo.mbsp.model.routing.Route"
*
* @hibernate.generator-param
* name = "sequence"
* value = "sq_id_mbsp_route"
*
* @hibernate.idbag lazy = "false" table = "MBSP_ROUTE" order-by = "POSITION
* asc"
* @hibernate.key column = "ROUTING_TABLE_ID"
*/
public List<Route> getRoutes() {
return routes;
}
public void setRoutes(List<Route> routes) {
this.routes = routes;
}
on sql server, when saving the RoutingTable with new Routes on, this causes a classcast exception:
Code:
2009-07-02 10:18:26,369 [http-8443-3] INFO STDOUT - Hibernate: insert into MBSP_ROUTE (ROUTING_TABLE_ID, ID, OPERATOR_ID, CHANNEL_ID, POSITION) values (?, ?, ?, ?, ?)
2009-07-02 10:18:26,370 [http-8443-3] INFO LongType - could not bind value 'POST_INSERT_INDICATOR' to parameter: 2; org.hibernate.id.IdentifierGeneratorFactory$2
2009-07-02 10:18:26,371 [http-8443-3] WARN arjLoggerI18N - [com.arjuna.ats.arjuna.coordinator.TwoPhaseCoordinator_2] TwoPhaseCoordinator.beforeCompletion - failed for com.arjuna.ats.internal.jta.resources.arjunacore.SynchronizationImple@1b853a5
java.lang.ClassCastException: org.hibernate.id.IdentifierGeneratorFactory$2
at org.hibernate.type.LongType.set(LongType.java:42)
at org.hibernate.type.NullableType.nullSafeSet(NullableType.java:136)
at org.hibernate.type.NullableType.nullSafeSet(NullableType.java:116)
at org.hibernate.persister.collection.AbstractCollectionPersister.writeIdentifier(AbstractCollectionPersister.java:807)
at org.hibernate.persister.collection.AbstractCollectionPersister.insertRows(AbstractCollectionPersister.java:1359)
at org.hibernate.action.CollectionUpdateAction.execute(CollectionUpdateAction.java:56)
there are multiple problems:
1) hibernate seems to try to insert a value into the identity field (ID), how can i avoid this / from the log snippet i guess hibernate tries to insert a long (0?) instead of a null value for the ID can this be configured to be null?
2) why cant POST_INSERT_INDICATOR value be bound?
3) is the classcast exception caused by trying to insert a value into the identifier field - or?
can anyone help me on with this please?
thanx!
dom