-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: hibernate composite element native id generation fails
PostPosted: Wed Jul 01, 2009 10:06 am 
Newbie

Joined: Wed Jul 01, 2009 9:50 am
Posts: 1
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


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.