-->
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.  [ 3 posts ] 
Author Message
 Post subject: when hibernate insert before creat?
PostPosted: Fri Aug 20, 2004 9:19 am 
Newbie

Joined: Fri Aug 20, 2004 9:06 am
Posts: 2
Hibernate version:
2.1.4
Mapping documents:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping
PUBLIC "-//Hibernate/Hibernate Mapping DTD//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">

<hibernate-mapping>

<class name="com.testhibernate.pocSubscriber" table="USER">
<!-- A 32 hex character is our surrogate key. It's automatically
generated by Hibernate with the UUID pattern. -->
<id name="userID" type="java.lang.Long">
<generator class="assigned"/>
</id>
<property name="dnDFlag" type="java.lang.Boolean" column ="DND" />

</class>

</hibernate-mapping>

Code between sessionFactory.openSession() and session.close():

pocSubscriber user1 =new pocSubscriber();
user1.setUserID(1);
user1.setDnDFlag(true);
s.save(user1);

Full stack trace of any exception that occurs:
20:51:22,203 INFO Environment:462 - Hibernate 2.1.4


20:51:22,250 INFO Environment:496 - loaded properties from resource hibernate.properties: {hibernate.connection.driver_class=org.postgresql.Driver, hibernate.cglib.use_reflection_optimizer=true, hibernate.cache.provider_class=net.sf.ehcache.hibernate.Provider, hibernate.cache.use_query_cache=true, hibernate.max_fetch_depth=1, hibernate.dialect=net.sf.hibernate.dialect.PostgreSQLDialect, hibernate.jdbc.use_streams_for_binary=true, hibernate.jdbc.batch_size=0, hibernate.query.substitutions=yes 'Y', no 'N', hibernate.proxool.pool_alias=pool1, hibernate.connection.username=postgres, hibernate.cache.region_prefix=hibernate.test, hibernate.connection.url=jdbc:postgresql://xxxxx/GMLS, hibernate.show_sql=true, hibernate.connection.password=clear, hibernate.connection.pool_size=1}


20:51:22,453 INFO Environment:521 - using java.io streams to persist binary types


20:51:22,453 INFO Environment:522 - using CGLIB reflection optimizer


20:51:22,546 INFO Configuration:347 - Mapping resource: com/testhibernate/pocSubscriber.hbm.xml


20:51:24,843 INFO Binder:229 - Mapping class: com.testhibernate.pocSubscriber -> USER


20:51:25,390 INFO Configuration:613 - processing one-to-many association mappings


20:51:25,406 INFO Configuration:622 - processing one-to-one association property references


20:51:25,406 INFO Configuration:647 - processing foreign key constraints


20:51:25,546 INFO Dialect:82 - Using dialect: net.sf.hibernate.dialect.PostgreSQLDialect


20:51:25,593 INFO SettingsFactory:58 - Maximim outer join fetch depth: 1


20:51:25,609 INFO SettingsFactory:62 - Use outer join fetching: true


20:51:25,640 INFO DriverManagerConnectionProvider:42 - Using Hibernate built-in connection pool (not for production use!)


20:51:25,640 INFO DriverManagerConnectionProvider:43 - Hibernate connection pool size: 1


20:51:25,671 INFO DriverManagerConnectionProvider:77 - using driver: org.postgresql.Driver at URL: jdbc:postgresql://192.168.6.2:3333/GMLS


20:51:25,796 INFO DriverManagerConnectionProvider:78 - connection properties: {user=postgres, password=clear}


20:51:25,890 INFO TransactionManagerLookupFactory:33 - No TransactionManagerLookup configured (in JTA environment, use of process level read-write cache is not recommended)


20:51:26,515 INFO SettingsFactory:102 - Use scrollable result sets: true


20:51:26,515 INFO SettingsFactory:105 - Use JDBC3 getGeneratedKeys(): false


20:51:26,515 INFO SettingsFactory:108 - Optimize cache for minimal puts: false


20:51:26,515 INFO SettingsFactory:114 - echoing all SQL to stdout


20:51:26,531 INFO SettingsFactory:117 - Query language substitutions: {no='N', yes='Y'}


20:51:26,531 INFO SettingsFactory:128 - cache provider: net.sf.ehcache.hibernate.Provider


20:51:26,609 INFO Configuration:1093 - instantiating and configuring caches


20:51:28,625 INFO SessionFactoryImpl:119 - building session factory


20:51:33,359 INFO SessionFactoryObjectFactory:82 - no JNDI name configured


20:51:33,375 INFO UpdateTimestampsCache:35 - starting update timestamps cache at region: net.sf.hibernate.cache.UpdateTimestampsCache


20:51:33,718 WARN Plugin:95 - Could not find configuration for net.sf.hibernate.cache.UpdateTimestampsCache. Configuring using the defaultCache settings.


20:51:33,750 INFO QueryCache:39 - starting query cache at region: net.sf.hibernate.cache.QueryCache


20:51:33,750 WARN Plugin:95 - Could not find configuration for net.sf.hibernate.cache.QueryCache. Configuring using the defaultCache settings.


Hibernate: insert into USER (DND, userID) values (?, ?)


20:51:34,390 WARN JDBCExceptionReporter:38 - SQL Error: 0, SQLState: null


20:51:34,390 ERROR JDBCExceptionReporter:46 - ERROR: parser: parse error at or near "USER" at character 13




20:51:34,406 ERROR JDBCExceptionReporter:38 - could not insert: [com.testhibernate.pocSubscriber#1]


java.sql.SQLException: ERROR: parser: parse error at or near "USER" at character 13




at org.postgresql.core.QueryExecutor.execute(QueryExecutor.java:131)


at org.postgresql.jdbc1.AbstractJdbc1Connection.ExecSQL(AbstractJdbc1Connection.java:505)


at org.postgresql.jdbc1.AbstractJdbc1Statement.execute(AbstractJdbc1Statement.java:320)


at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:48)


at org.postgresql.jdbc1.AbstractJdbc1Statement.executeUpdate(AbstractJdbc1Statement.java:197)


at net.sf.hibernate.impl.NonBatchingBatcher.addToBatch(NonBatchingBatcher.java:22)


at net.sf.hibernate.persister.EntityPersister.insert(EntityPersister.java:468)


at net.sf.hibernate.persister.EntityPersister.insert(EntityPersister.java:442)


at net.sf.hibernate.impl.ScheduledInsertion.execute(ScheduledInsertion.java:29)


at net.sf.hibernate.impl.SessionImpl.executeAll(SessionImpl.java:2414)


at net.sf.hibernate.impl.SessionImpl.execute(SessionImpl.java:2367)


at net.sf.hibernate.impl.SessionImpl.flush(SessionImpl.java:2236)


at net.sf.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:61)


at pocTest.main(pocTest.java:22)


20:51:34,421 ERROR SessionImpl:2375 - Could not synchronize database state with session


net.sf.hibernate.JDBCException: could not insert: [com.testhibernate.pocSubscriber#1]


at net.sf.hibernate.persister.EntityPersister.insert(EntityPersister.java:478)


at net.sf.hibernate.persister.EntityPersister.insert(EntityPersister.java:442)


at net.sf.hibernate.impl.ScheduledInsertion.execute(ScheduledInsertion.java:29)


at net.sf.hibernate.impl.SessionImpl.executeAll(SessionImpl.java:2414)


at net.sf.hibernate.impl.SessionImpl.execute(SessionImpl.java:2367)


at net.sf.hibernate.impl.SessionImpl.flush(SessionImpl.java:2236)


at net.sf.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:61)


at pocTest.main(pocTest.java:22)


Caused by: java.sql.SQLException: ERROR: parser: parse error at or near "USER" at character 13




at org.postgresql.core.QueryExecutor.execute(QueryExecutor.java:131)


at org.postgresql.jdbc1.AbstractJdbc1Connection.ExecSQL(AbstractJdbc1Connection.java:505)


at org.postgresql.jdbc1.AbstractJdbc1Statement.execute(AbstractJdbc1Statement.java:320)


at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:48)


at org.postgresql.jdbc1.AbstractJdbc1Statement.executeUpdate(AbstractJdbc1Statement.java:197)


at net.sf.hibernate.impl.NonBatchingBatcher.addToBatch(NonBatchingBatcher.java:22)


at net.sf.hibernate.persister.EntityPersister.insert(EntityPersister.java:468)


... 7 more


net.sf.hibernate.JDBCException: could not insert: [com.testhibernate.pocSubscriber#1]


at net.sf.hibernate.persister.EntityPersister.insert(EntityPersister.java:478)


at net.sf.hibernate.persister.EntityPersister.insert(EntityPersister.java:442)


at net.sf.hibernate.impl.ScheduledInsertion.execute(ScheduledInsertion.java:29)


at net.sf.hibernate.impl.SessionImpl.executeAll(SessionImpl.java:2414)


at net.sf.hibernate.impl.SessionImpl.execute(SessionImpl.java:2367)


at net.sf.hibernate.impl.SessionImpl.flush(SessionImpl.java:2236)


at net.sf.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:61)


at pocTest.main(pocTest.java:22)


Caused by: java.sql.SQLException: ERROR: parser: parse error at or near "USER" at character 13




at org.postgresql.core.QueryExecutor.execute(QueryExecutor.java:131)


at org.postgresql.jdbc1.AbstractJdbc1Connection.ExecSQL(AbstractJdbc1Connection.java:505)


at org.postgresql.jdbc1.AbstractJdbc1Statement.execute(AbstractJdbc1Statement.java:320)


at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:48)


at org.postgresql.jdbc1.AbstractJdbc1Statement.executeUpdate(AbstractJdbc1Statement.java:197)


at net.sf.hibernate.impl.NonBatchingBatcher.addToBatch(NonBatchingBatcher.java:22)


at net.sf.hibernate.persister.EntityPersister.insert(EntityPersister.java:468)


... 7 more


Exception in thread "main"


Name and version of the database you are using:
postgrelsql7.3.6


when i test this simple program, i was confused that No creat sql is used befor the Hibernate: insert into USER (DND, userID) values (?, ?)
and when the values(?,?) i have set them. The jdbc driver report parse ERROR. I am worry and uppset about the problem,Is there anybody who can help me ,Thanks very much


Top
 Profile  
 
 Post subject:
PostPosted: Fri Aug 20, 2004 10:55 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
I assume USER is a reserved word in postgres.


Top
 Profile  
 
 Post subject:
PostPosted: Sun Aug 22, 2004 8:55 am 
Newbie

Joined: Fri Aug 20, 2004 9:06 am
Posts: 2
thank you very much for your replying ,but i am afraid it is not the USER is reserved problem ,I change the name USER to POCUSER,the error is still there


but the same code , i put make write a newfile "pocTest" by copy a lot from other ***test in the hibernate's test directionary and put it there ,
and just type junitreport ,IT WORKS . NOW it first creat the table and then insert one line ,there is no error any more ,I just don't what is the difference , and why ?


i am a begin to hibernate , please help me thanks a lot


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

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.