-->
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: Cannot Create Event Object(from Tutorial) in Oracle DB
PostPosted: Thu Sep 29, 2005 9:53 pm 
Newbie

Joined: Thu Sep 29, 2005 9:38 pm
Posts: 1
[newbie]
I'm trying to follow the Hibernate Documentation and I copied Event Object and its mapping file and all the rest as mentioned in the doc. Only difference being the database. I'm using Oracle Database. Everything compiles fine but when run, it generates this output (among lots of other output, most of which looks ok):


[java] Exception in thread "main" org.hibernate.HibernateException: identifier of an instance of Event altered from 1 to null


Obviously, the Object doesn't save.

For those who like details, complete output is at the bottom of this post.

Hibernate version: 3.0.5

Mapping documents:
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0 //EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">

<hibernate-mapping>
<class name='Event' table='EVENTS'>
<id name='id' column='EVENT_ID'>
<generator class='increment'/>
</id>
<property name='date' type='timestamp' column='EVENT_DATE'/>
<property name='title' column='EVENT_TITLE'/>
</class>
</hibernate-mapping>

Code between sessionFactory.openSession() and session.close():
Transaction tx = session.beginTransaction();

Event e = new Event();
e.setTitle("NEW Event");
e.setDate(new Date());

session.save(e);
tx.commit();

Name and version of the database you are using:
Oracle 10g

Full stack trace of any exception that occurs:
Buildfile: build.xml

clean:
[delete] Deleting directory /home/praveen/java_projects/test/hibernate/bin
[mkdir] Created dir: /home/praveen/java_projects/test/hibernate/bin

copy-resources:
[copy] Copying 3 files to /home/praveen/java_projects/test/hibernate/bin

compile:
[javac] Compiling 3 source files to /home/praveen/java_projects/test/hibernate/bin

run:
[java] 21:49:58,027 INFO Environment:464 - Hibernate 3.0.5
[java] 21:49:58,038 INFO Environment:477 - hibernate.properties not found
[java] 21:49:58,048 INFO Environment:510 - using CGLIB reflection optimizer
[java] 21:49:58,093 INFO Environment:540 - using JDK 1.4 java.sql.Timestamp handling
[java] 21:49:58,248 INFO Configuration:1110 - configuring from resource: /hibernate.cfg.xml
[java] 21:49:58,249 INFO Configuration:1081 - Configuration resource: /hibernate.cfg.xml
[java] 21:49:58,839 INFO Configuration:444 - Mapping resource: Event.hbm.xml
[java] 21:49:59,084 INFO HbmBinder:260 - Mapping class: Event -> EVENTS
[java] 21:49:59,126 INFO Configuration:1222 - Configured SessionFactory: null
[java] 21:49:59,130 INFO Configuration:875 - processing extends queue
[java] 21:49:59,131 INFO Configuration:879 - processing collection mappings
[java] 21:49:59,132 INFO Configuration:888 - processing association property references
[java] 21:49:59,134 INFO Configuration:917 - processing foreign key constraints
[java] 21:49:59,435 INFO DriverManagerConnectionProvider:41 - Using Hibernate built-in connection pool (not for production use!)
[java] 21:49:59,436 INFO DriverManagerConnectionProvider:42 - Hibernate connection pool size: 1
[java] 21:49:59,437 INFO DriverManagerConnectionProvider:45 - autocommit mode: false
[java] 21:49:59,483 INFO DriverManagerConnectionProvider:80 - using driver: oracle.jdbc.driver.OracleDriver at URL: jdbc:oracle:thin:@localhost:1521/orcl.TOO
[java] 21:49:59,484 INFO DriverManagerConnectionProvider:86 - connection properties: {user=java_play, password=****}
[java] 21:50:04,599 INFO SettingsFactory:77 - RDBMS: Oracle, version: Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
[java] With the Partitioning, OLAP and Data Mining options
[java] 21:50:04,599 INFO SettingsFactory:78 - JDBC driver: Oracle JDBC driver, version: 10.2.0.1.0
[java] 21:50:04,641 INFO Dialect:92 - Using dialect: org.hibernate.dialect.HSQLDialect
[java] 21:50:04,669 INFO TransactionFactoryFactory:31 - Using default transaction strategy (direct JDBC transactions)
[java] 21:50:04,673 INFO TransactionManagerLookupFactory:33 - No TransactionManagerLookup configured (in JTA environment, use of read-write or transactional second-level cache is not recommended)
[java] 21:50:04,674 INFO SettingsFactory:125 - Automatic flush during beforeCompletion(): disabled
[java] 21:50:04,675 INFO SettingsFactory:129 - Automatic session close at end of transaction: disabled
[java] 21:50:04,675 INFO SettingsFactory:136 - JDBC batch size: 15
[java] 21:50:04,676 INFO SettingsFactory:139 - JDBC batch updates for versioned data: disabled
[java] 21:50:04,677 INFO SettingsFactory:144 - Scrollable result sets: enabled
[java] 21:50:04,678 INFO SettingsFactory:152 - JDBC3 getGeneratedKeys(): enabled
[java] 21:50:04,681 INFO SettingsFactory:160 - Connection release mode: null
[java] 21:50:04,683 INFO SettingsFactory:187 - Default batch fetch size: 1
[java] 21:50:04,684 INFO SettingsFactory:191 - Generate SQL with comments: disabled
[java] 21:50:04,684 INFO SettingsFactory:195 - Order SQL updates by primary key: disabled
[java] 21:50:04,687 INFO SettingsFactory:334 - Query translator: org.hibernate.hql.ast.ASTQueryTranslatorFactory
[java] 21:50:04,701 INFO ASTQueryTranslatorFactory:21 - Using ASTQueryTranslatorFactory
[java] 21:50:04,702 INFO SettingsFactory:203 - Query language substitutions: {}
[java] 21:50:04,703 INFO SettingsFactory:209 - Second-level cache: enabled
[java] 21:50:04,703 INFO SettingsFactory:213 - Query cache: disabled
[java] 21:50:04,704 INFO SettingsFactory:321 - Cache provider: org.hibernate.cache.EhCacheProvider
[java] 21:50:04,713 INFO SettingsFactory:228 - Optimize cache for minimal puts: disabled
[java] 21:50:04,715 INFO SettingsFactory:237 - Structured second-level cache entries: disabled
[java] 21:50:04,728 INFO SettingsFactory:257 - Echoing all SQL to stdout
[java] 21:50:04,736 INFO SettingsFactory:261 - Statistics: disabled
[java] 21:50:04,736 INFO SettingsFactory:265 - Deleted entity synthetic identifier rollback: disabled
[java] 21:50:04,737 INFO SettingsFactory:279 - Default entity-mode: pojo
[java] 21:50:04,994 INFO SessionFactoryImpl:152 - building session factory
[java] 21:50:05,016 WARN Configurator:126 - No configuration found. Configuring ehcache from ehcache-failsafe.xml found in the classpath: jar:file:/home/praveen/java_projects/test/hibernate/lib/ehcache-1.1.jar!/ehcache-failsafe.xml
[java] 21:50:05,585 INFO SessionFactoryObjectFactory:82 - Not binding factory to JNDI, no JNDI name configured
[java] 21:50:05,586 INFO SessionFactoryImpl:379 - Checking 0 named queries
[java] Exception in thread "main" org.hibernate.HibernateException: identifier of an instance of Event altered from 1 to null
[java] at org.hibernate.event.def.DefaultFlushEntityEventListener.checkId(DefaultFlushEntityEventListener.java:51)
[java] at org.hibernate.event.def.DefaultFlushEntityEventListener.onFlushEntity(DefaultFlushEntityEventListener.java:82)
[java] at org.hibernate.event.def.AbstractFlushingEventListener.flushEntities(AbstractFlushingEventListener.java:190)
[java] at org.hibernate.event.def.AbstractFlushingEventListener.flushEverythingToExecutions(AbstractFlushingEventListener.java:70)
[java] at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:26)
[java] at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:730)
[java] at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:324)
[java] at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:86)
[java] at hb_01.main(Unknown Source)
[java] Java Result: 1

BUILD SUCCESSFUL
Total time: 21 seconds


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.