-->
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: insert into table failing (newbie)
PostPosted: Sat Feb 19, 2005 1:42 am 
Newbie

Joined: Sat Feb 19, 2005 1:34 am
Posts: 5
Hi guys

i'm trying to persist a simple object model into hypersonic. i think i have set everything up correctly but it's failing to do an Insert. i can manually insert so the DB is working ok. Any ideas?

Thanks
Paul




Hibernate version: = 2.1

Mapping documents:

<hibernate-mapping>
<class name="com.workflow.WorkFlow"
table="workflow">
<id name="id" type="string"
unsaved-value="null">
<column name="id" sql-type="char(32)"
not-null="true"/>
<generator class="uuid.hex"/>
</id>
<property name="name">
<column name="name" sql-type="char(255)"
not-null="true"/>
</property>
<set name="activities" table="activity" inverse="true" cascade="all">
<key column="id" />
<one-to-many class="com.workflow.Activity" />
</set>
</class>
</hibernate-mapping>




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

public void persist(WorkFlow workflow)
throws WorkFlowException{
try{
Configuration cfg = new Configuration()
.addClass(WorkFlow.class);
cfg.addClass(Activity.class);
cfg.addClass(Transition.class);
SessionFactory sf = cfg.buildSessionFactory();
Session sess = sf.openSession();
Transaction t = sess.beginTransaction();
sess.save(workflow);
t.commit();
sess.close();
}
catch(Exception e){
throw new WorkFlowException(e.getMessage());
}
}





Full stack trace of any exception that occurs:

test:
[junit] Testsuite: com.workflow.MainTest
[junit] Tests run: 1, Failures: 0, Errors: 0, Time elapsed: 1.622 sec
[junit] ------------- Standard Output ---------------
[junit] 16:14:39,758 INFO - Added Transition (source=A1,target=A2)
[junit] 16:14:39,758 INFO - Added Transition (source=A1,target=A3)
[junit] 16:14:39,758 INFO - Added Activity=A1
[junit] 16:14:39,768 INFO - Added Transition (source=A2,target=A3)
[junit] 16:14:39,768 INFO - Added Activity=A2
[junit] 16:14:39,768 INFO - Created a Workflow=W1
[junit] 16:14:39,788 INFO - Hibernate 2.1.8
[junit] 16:14:39,788 INFO - loaded properties from resource hibernate.properties: {hibernate.connection.username=sa, hibernate
.connection.password=, hibernate.cglib.use_reflection_optimizer=true, hibernate.dialect=net.sf.hibernate.dialect.HSQLDialect, hibern
ate.show_sql=true, hibernate.connection.url=jdbc:hsqldb:hsql://localhost/mydb, hibernate.connection.driver_class=org.hsqldb.jdbcDriv
er}
[junit] 16:14:39,788 INFO - using CGLIB reflection optimizer
[junit] 16:14:39,788 INFO - using JDK 1.4 java.sql.Timestamp handling
[junit] 16:14:39,798 INFO - Mapping resource: com/workflow/WorkFlow.hbm.xml
[junit] 16:14:40,018 INFO - Mapping class: com.workflow.WorkFlow -> workflow
[junit] 16:14:40,098 INFO - Mapping resource: com/workflow/Activity.hbm.xml
[junit] 16:14:40,128 INFO - Mapping class: com.workflow.Activity -> activity
[junit] 16:14:40,128 INFO - Mapping resource: com/workflow/Transition.hbm.xml
[junit] 16:14:40,158 INFO - Mapping class: com.workflow.Transition -> transition
[junit] 16:14:40,158 INFO - processing one-to-many association mappings
[junit] 16:14:40,158 INFO - Mapping collection: com.workflow.WorkFlow.activities -> activity
[junit] 16:14:40,158 INFO - Mapping collection: com.workflow.Activity.transitions -> transition
[junit] 16:14:40,168 INFO - processing one-to-one association property references
[junit] 16:14:40,168 INFO - processing foreign key constraints
[junit] 16:14:40,188 INFO - Using dialect: net.sf.hibernate.dialect.HSQLDialect
[junit] 16:14:40,198 INFO - Use outer join fetching: true
[junit] 16:14:40,208 INFO - Using Hibernate built-in connection pool (not for production use!)
[junit] 16:14:40,208 INFO - Hibernate connection pool size: 20
[junit] 16:14:40,208 INFO - using driver: org.hsqldb.jdbcDriver at URL: jdbc:hsqldb:hsql://localhost/mydb
[junit] 16:14:40,208 INFO - connection properties: {user=sa, password=}
[junit] 16:14:40,218 INFO - No TransactionManagerLookup configured (in JTA environment, use of process level read-write cache
is not recommended)
[junit] 16:14:40,348 INFO - Use scrollable result sets: true
[junit] 16:14:40,348 INFO - Use JDBC3 getGeneratedKeys(): false
[junit] 16:14:40,348 INFO - Optimize cache for minimal puts: false
[junit] 16:14:40,348 INFO - echoing all SQL to stdout
[junit] 16:14:40,348 INFO - Query language substitutions: {}
[junit] 16:14:40,348 INFO - cache provider: net.sf.hibernate.cache.EhCacheProvider
[junit] 16:14:40,358 INFO - instantiating and configuring caches
[junit] 16:14:40,368 WARN - No configuration found. Configuring ehcache from ehcache-failsafe.xml found in the classpath: jar:
file:/C:/eclipse/workspace/workflow/lib/ehcache-0.9.jar!/ehcache-failsafe.xml
[junit] 16:14:40,499 INFO - building session factory
[junit] 16:14:40,799 INFO - Not binding factory to JNDI, no JNDI name configured
[junit] Hibernate: insert into workflow (name, id) values (?, ?)
[junit] 16:14:40,889 WARN - SQL Error: -22, SQLState: S0002
[junit] 16:14:40,889 ERROR - Table not found: WORKFLOW in statement [insert into workflow (name, id) values (?, ?)]
[junit] 16:14:40,889 WARN - SQL Error: -22, SQLState: S0002
[junit] 16:14:40,889 ERROR - Table not found: WORKFLOW in statement [insert into workflow (name, id) values (?, ?)]
[junit] 16:14:40,889 ERROR - Could not synchronize database state with session
[junit] ------------- ---------------- ---------------
[junit] ------------- Standard Error -----------------
[junit] com.workflow.WorkFlowException: could not insert: [com.workflow.WorkFlow#297e9901022909f301022909f
5510001]
[junit] at com.workflow.WorkFlowPersister.persist(WorkFlowPersister.java:29)
[junit] at com.workflow.Main.<init>(Main.java:7)
[junit] at com.workflow.MainTest.setUp(MainTest.java:17)
[junit] at junit.framework.TestCase.runBare(TestCase.java:125)
[junit] at junit.framework.TestResult$1.protect(TestResult.java:106)
[junit] at junit.framework.TestResult.runProtected(TestResult.java:124)
[junit] at junit.framework.TestResult.run(TestResult.java:109)
[junit] at junit.framework.TestCase.run(TestCase.java:118)
[junit] at junit.framework.TestSuite.runTest(TestSuite.java:208)
[junit] at junit.framework.TestSuite.run(TestSuite.java:203)
[junit] at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.run(JUnitTestRunner.java:325)
[junit] at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.main(JUnitTestRunner.java:524)
[junit] ------------- ---------------- ---------------

[junit] Testcase: testInstantiation took 1.622 sec



Name and version of the database you are using:

Hypersonic SQL 1.7.3

CREATE TABLE TRANSITION(
ID VARCHAR NOT NULL PRIMARY KEY,
NAME VARCHAR NOT NULL,
SOURCE_ACTIVITY_ID VARCHAR NOT NULL,
TARGET_ACTIVITY_ID VARCHAR NOT NULL)

CREATE TABLE ACTIVITY(
ID VARCHAR NOT NULL PRIMARY KEY,
NAME VARCHAR NOT NULL,
TRANSITION_ID VARCHAR NOT NULL,
WORKFLOW_ID VARCHAR NOT NULL)

CREATE TABLE WORKFLOW(
ID VARCHAR NOT NULL PRIMARY KEY,
NAME VARCHAR)



The generated SQL (show_sql=true):

insert into workflow (name, id) values (?, ?)


Top
 Profile  
 
 Post subject:
PostPosted: Sat Feb 19, 2005 12:55 pm 
Beginner
Beginner

Joined: Tue Sep 09, 2003 9:11 pm
Posts: 32
Are Hypersonic table names case sensitive? I ran into this with MySQL on windows.


Top
 Profile  
 
 Post subject: Do other actions work?
PostPosted: Sat Feb 19, 2005 3:20 pm 
Regular
Regular

Joined: Thu Dec 18, 2003 2:14 am
Posts: 103
Location: Brooklyn, NY
Does a basic read work? Try simple stuff, and test your connection, before implementing inserts. I use the HibernateConsole tool to test my config and mappings before writing a stitch of app code. Also test my HQL there.

http://hibernate.org/259.html for 2.1

http://www.hibernate.org/255.html for 3.0b4 and Eclipse


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.