-->
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: Tabelle wird nicht angelegt
PostPosted: Sun May 08, 2005 7:20 pm 
Newbie

Joined: Sun May 08, 2005 6:43 pm
Posts: 4
Hi,
dies sind meine ersten Versuche mit Hibernate und Derby.
Habe eigentlich alles entsprechend der Hibernate-Doku konfiguriert und möchte nun ein Objekt meiner Klasse User speichern.
Leider wird die Tabelle user nicht angelegt.
Ich finde den Fehler einfach nicht. Vielleicht kann jemand helfen?

Vielen Dank!


Hibernate version:3.0.2

Name and version of the database: Derby 10.0.2.1

Mapping documents:
User.hbm.xml:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">

<hibernate-mapping>

<class name="model.user.User" table="user">
<id name="id" column="id" type="long" unsaved-value="null">
<generator class="increment"/>
</id>
<property name="name" column="name" type="string"/>
<property name="password" column="password" type="string"/>
<property name="sex" column="sex" type="string"/>
<property name="age" column="age" type="string"/>
<property name="height" column="height" type="string"/>
<property name="weight" column="weight" type="string"/>
</class>

</hibernate-mapping>

hibernate.cfg.xml:
<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"

"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">

<hibernate-configuration>

<session-factory>
<property name="hibernate.connection.driver_class">org.apache.derby.jdbc.EmbeddedDriver</property>
<property name="hibernate.connection.url">jdbc:derby:/tfh/diplom/ernaehrungscoach/derbyDB/nutritionCoach;create=true</property>
<property name="hibernate.connection.username">sa</property>
<property name="hibernate.connection.password"></property>
<property name="dialect">org.hibernate.dialect.DerbyDialect</property>
<property name="show_sql">true</property>
<property name="transaction.factory_class">
org.hibernate.transaction.JDBCTransactionFactory
</property>
<property name="hibernate.cache.provider_class">
org.hibernate.cache.HashtableCacheProvider
</property>
<property name="hibernate.hbm2ddl.auto">update</property>

<mapping resource="model/user/User.hbm.xml"/>

</session-factory>

</hibernate-configuration>

Code between sessionFactory.openSession() and session.close():
//Person in Datenbank speichern
try {
sf = new Configuration().configure().buildSessionFactory();
session = sf.openSession();
trx = session.beginTransaction();
User user = new User (name, password, sex, age, hight, weight);
session.save(user);
trx.commit();
}
catch(HibernateException ex) {
if(trx != null){
try {trx.rollback();}
catch(HibernateException exRb) {}
throw new RuntimeException(ex.getMessage());
}
}
finally {
try {session.close();}
catch(Exception exCl) {}
}

Full stack trace of any exception that occurs:
01:10:14,562 INFO Environment:464 - Hibernate 3.0.2
01:10:14,578 INFO Environment:477 - hibernate.properties not found
01:10:14,593 INFO Environment:510 - using CGLIB reflection optimizer
01:10:14,609 INFO Environment:540 - using JDK 1.4 java.sql.Timestamp handling
01:10:14,796 INFO Configuration:1160 - configuring from resource: /hibernate.cfg.xml
01:10:14,812 INFO Configuration:1131 - Configuration resource: /hibernate.cfg.xml
01:10:15,250 INFO Configuration:441 - Mapping resource: model/user/User.hbm.xml
01:10:15,671 INFO HbmBinder:258 - Mapping class: model.user.User -> user
01:10:15,718 INFO Configuration:1272 - Configured SessionFactory: null
01:10:15,734 INFO Configuration:852 - processing extends queue
01:10:15,734 INFO Configuration:856 - processing collection mappings
01:10:15,734 INFO Configuration:865 - processing association property references
01:10:15,734 INFO Configuration:894 - processing foreign key constraints
01:10:15,968 INFO DriverManagerConnectionProvider:41 - Using Hibernate built-in connection pool (not for production use!)
01:10:15,984 INFO DriverManagerConnectionProvider:42 - Hibernate connection pool size: 20
01:10:15,984 INFO DriverManagerConnectionProvider:45 - autocommit mode: false
01:10:17,203 INFO DriverManagerConnectionProvider:80 - using driver: org.apache.derby.jdbc.EmbeddedDriver at URL: jdbc:derby:/tfh/diplom/ernaehrungscoach/derbyDB/nutritionCoach;create=true
01:10:17,203 INFO DriverManagerConnectionProvider:86 - connection properties: {user=sa, password=****}
01:10:18,546 INFO SettingsFactory:71 - RDBMS: Apache Derby, version: 10.0.2.1
01:10:18,546 INFO SettingsFactory:72 - JDBC driver: Apache Derby Embedded JDBC Driver, version: 10.0.2.1
01:10:18,625 INFO Dialect:92 - Using dialect: org.hibernate.dialect.DerbyDialect
01:10:18,656 INFO SettingsFactory:130 - Scrollable result sets: enabled
01:10:18,656 INFO SettingsFactory:138 - JDBC3 getGeneratedKeys(): enabled
01:10:18,656 INFO SettingsFactory:150 - Aggressive release : disabled
01:10:18,671 INFO SettingsFactory:166 - Default batch fetch size: 1
01:10:18,671 INFO SettingsFactory:170 - Generate SQL with comments: disabled
01:10:18,671 INFO SettingsFactory:174 - Order SQL updates by primary key: disabled
01:10:18,671 INFO SettingsFactory:312 - Query translator: org.hibernate.hql.ast.ASTQueryTranslatorFactory
01:10:18,687 INFO ASTQueryTranslatorFactory:21 - Using ASTQueryTranslatorFactory
01:10:18,687 INFO SettingsFactory:182 - Query language substitutions: {}
01:10:18,703 INFO TransactionFactoryFactory:34 - Transaction strategy: org.hibernate.transaction.JDBCTransactionFactory
01:10:18,718 INFO TransactionManagerLookupFactory:33 - No TransactionManagerLookup configured (in JTA environment, use of read-write or transactional second-level cache is not recommended)
01:10:18,718 INFO SettingsFactory:191 - Automatic flush during beforeCompletion(): disabled
01:10:18,734 INFO SettingsFactory:195 - Automatic session close at end of transaction: disabled
01:10:18,734 INFO SettingsFactory:201 - Second-level cache: enabled
01:10:18,734 INFO SettingsFactory:205 - Query cache: disabled
01:10:18,734 INFO SettingsFactory:299 - Cache provider: org.hibernate.cache.HashtableCacheProvider
01:10:18,750 INFO SettingsFactory:220 - Optimize cache for minimal puts: disabled
01:10:18,750 INFO SettingsFactory:229 - Structured second-level cache entries: enabled
01:10:18,765 INFO SettingsFactory:249 - Echoing all SQL to stdout
01:10:18,765 INFO SettingsFactory:253 - Statistics: disabled
01:10:18,765 INFO SettingsFactory:257 - Deleted entity synthetic identifier rollback: disabled
01:10:18,765 INFO SettingsFactory:271 - Default entity-mode: pojo
01:10:20,171 INFO SessionFactoryImpl:148 - building session factory
im Def-Konstruktor von User
im Def-Konstruktor von User
01:10:20,968 INFO SessionFactoryObjectFactory:82 - Not binding factory to JNDI, no JNDI name configured
01:10:20,984 INFO Dialect:92 - Using dialect: org.hibernate.dialect.DerbyDialect
01:10:20,984 INFO DriverManagerConnectionProvider:41 - Using Hibernate built-in connection pool (not for production use!)
01:10:20,984 INFO DriverManagerConnectionProvider:42 - Hibernate connection pool size: 20
01:10:20,984 INFO DriverManagerConnectionProvider:45 - autocommit mode: false
01:10:20,984 INFO DriverManagerConnectionProvider:80 - using driver: org.apache.derby.jdbc.EmbeddedDriver at URL: jdbc:derby:/tfh/diplom/ernaehrungscoach/derbyDB/nutritionCoach;create=true
01:10:20,984 INFO DriverManagerConnectionProvider:86 - connection properties: {user=sa, password=****}
01:10:20,984 INFO SchemaUpdate:105 - Running hbm2ddl schema update
01:10:20,984 INFO SchemaUpdate:117 - fetching database metadata
01:10:21,031 INFO SchemaUpdate:133 - updating schema
01:10:21,031 INFO Configuration:852 - processing extends queue
01:10:21,031 INFO Configuration:856 - processing collection mappings
01:10:21,031 INFO Configuration:865 - processing association property references
01:10:21,031 INFO Configuration:894 - processing foreign key constraints
01:10:22,718 INFO DatabaseMetadata:85 - table not found: user
01:10:22,734 INFO DatabaseMetadata:85 - table not found: user
01:10:22,734 DEBUG SchemaUpdate:142 - create table user (id bigint not null, name varchar(255), password varchar(255), sex varchar(255), age varchar(255), height varchar(255), weight varchar(255), primary key (id))
01:10:22,781 ERROR SchemaUpdate:148 - Unsuccessful: create table user (id bigint not null, name varchar(255), password varchar(255), sex varchar(255), age varchar(255), height varchar(255), weight varchar(255), primary key (id))
01:10:22,781 ERROR SchemaUpdate:149 - Syntax error: Encountered "user" at line 1, column 14.

01:10:22,781 INFO SchemaUpdate:153 - schema update complete
01:10:22,781 INFO DriverManagerConnectionProvider:147 - cleaning up connection pool: jdbc:derby:/tfh/diplom/ernaehrungscoach/derbyDB/nutritionCoach;create=true
01:10:22,781 INFO SessionFactoryImpl:374 - Checking 0 named queries
im Konstruktor von User
Name: a
Passwort: s
Geschlecht: männlich
Alter: 10
Größe: 100
Gewicht: 40
user: model.user.User@1c3e9ba
01:10:22,953 WARN JDBCExceptionReporter:71 - SQL Error: 20000, SQLState: 42X01
01:10:22,953 ERROR JDBCExceptionReporter:72 - Syntax error: Encountered "user" at line 1, column 21.
01:10:22,953 WARN JDBCExceptionReporter:48 - SQL Warning: 10000, SQLState: 01J01
01:10:22,953 WARN JDBCExceptionReporter:49 - Database '/tfh/diplom/ernaehrungscoach/derbyDB/nutritionCoach' not created, connection made to existing database instead.
Exception in thread "AWT-EventQueue-0" java.lang.RuntimeException: could not fetch initial value
at model.user.UserManager.createUser(UserManager.java:63)
at model.user.UserAdapter.actionPerformed(UserAdapter.java:52)
at event.ActionSupport.fireActionEvent(ActionSupport.java:58)
at gui.controller.Controller$ButtonActionListener.actionPerformed(Controller.java:51)
at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
at java.awt.Component.processMouseEvent(Unknown Source)
at javax.swing.JComponent.processMouseEvent(Unknown Source)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Container.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Window.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)


Top
 Profile  
 
 Post subject:
PostPosted: Sun May 08, 2005 8:02 pm 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
Wahrscheinlich ist "user" ein keyword. Hibernate kann das richtig quoten, einfach mit table="`user`" im mapping anlegen. Oder, und das ist besser, einen nicht-reservierten Namen verwenden.


Top
 Profile  
 
 Post subject:
PostPosted: Mon May 09, 2005 5:05 am 
Newbie

Joined: Sun May 08, 2005 6:43 pm
Posts: 4
Super, das war`s!

Vielen Dank, wäre ich so schnell nicht drauf gekommen...


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.