Using increment is wroking fine, But i want to know why it's not working with native or sequence. For my Mysql database i want to use native. don't want incriment and my mapping code is
<?xml version='1.0' encoding='UTF-8'?> <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd"> <hibernate-mapping> <class name="com.ssis.model.Item2" table="item2"> <id name="itemId"> <generator class="native"></generator> </id> <idbag name="images" table="timage2"> <collection-id type="long" column="imageid" > <generator class="native"></generator> </collection-id> <key column="itemId"></key> <element type="string" column="filename"></element> </idbag> <property name="name"></property> <property name="price"></property> </class> </hibernate-mappinv>
Can any one please answer . why I'm getting
Hibernate: insert into item2 (name, price) values (?, ?) Hibernate: insert into timage2 (itemId, imageid, filename) values (?, ?, ?) Exception in thread "main" java.lang.ClassCastException: org.hibernate.id.IdentifierGeneratorFactory$2 cannot be cast to java.lang.Long at org.hibernate.type.LongType.set(LongType.java:65) at org.hibernate.type.NullableType.nullSafeSet(NullableType.java:154) at org.hibernate.type.NullableType.nullSafeSet(NullableType.java:136) at org.hibernate.persister.collection.AbstractCollectionPersister.writeIdentifier(AbstractCollectionPersister.java:829) at org.hibernate.persister.collection.AbstractCollectionPersister.recreate(AbstractCollectionPersister.java:1160) at org.hibernate.action.CollectionRecreateAction.execute(CollectionRecreateAction.java:58) at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:279) at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:263) at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:171) at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:321) at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:50) at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1028) at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:366) at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:137) at ItemTest.main(ItemTest.java:24)
|