-->
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.  [ 2 posts ] 
Author Message
 Post subject: New to Hibernate and Java
PostPosted: Mon Mar 12, 2007 3:30 pm 
Newbie

Joined: Mon Mar 12, 2007 3:09 pm
Posts: 1
I am trying to Connect to HSQLDB engine through Hibernate as per the guidelines given in the tutorial....and I get the following error.Can anyone help me out with this ? I would also like to know how to connect to an MS ACCESS database thorugh Hibernate.




[java] 14:06:56,106 DEBUG SchemaExport:170 - import file not found: /import
.sql
[java] 14:06:56,106 INFO SchemaExport:179 - exporting generated schema to
database
[java] 14:06:56,137 DEBUG SchemaExport:303 - drop table EVENTS if exists
[java] 14:06:56,137 DEBUG SchemaExport:303 - create table EVENTS (EVENT_ID
bigint generated by default as identity (start with 1), EVENT_DATE timestamp, ti
tle varchar(255), primary key (EVENT_ID))
[java] 14:06:56,153 ERROR SchemaExport:274 - Unsuccessful: create table EVE
NTS (EVENT_ID bigint generated by default as identity (start with 1), EVENT_DATE
timestamp, title varchar(255), primary key (EVENT_ID))
[java] 14:06:56,153 ERROR SchemaExport:275 - Unexpected token: GENERATED in
statement [create table EVENTS (EVENT_ID bigint generated by default as identit
y (start with 1), EVENT_DATE timestamp, title varchar(255), primary key (EVENT_I
D))]
[java] 14:06:56,153 INFO SchemaExport:196 - schema export complete
[java] Hibernate: insert into EVENTS (EVENT_ID, EVENT_DATE, title) values (
null, ?, ?)
[java] 14:06:56,465 WARN JDBCExceptionReporter:77 - SQL Error: -22, SQLSta
te: S0002
[java] org.hibernate.exception.SQLGrammarException: could not insert: [even
ts.Event]
[java] at org.hibernate.exception.SQLStateConverter.convert(SQLStateCon
verter.java:67)
[java] 14:06:56,465 ERROR JDBCExceptionReporter:78 - Table not found: EVENT
S in statement [insert into EVENTS (EVENT_ID, EVENT_DATE, title) values (null, '
2007-03-12 14:06:54.013', 'My Event')]
[java] at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExcep
tionHelper.java:43)
[java] at org.hibernate.id.insert.AbstractSelectingDelegate.performInse
rt(AbstractSelectingDelegate.java:40)
[java] at org.hibernate.persister.entity.AbstractEntityPersister.insert
(AbstractEntityPersister.java:2154)
[java] at org.hibernate.persister.entity.AbstractEntityPersister.insert
(AbstractEntityPersister.java:2634)
[java] at org.hibernate.action.EntityIdentityInsertAction.execute(Entit
yIdentityInsertAction.java:48)


Top
 Profile  
 
 Post subject:
PostPosted: Sun Mar 25, 2007 11:11 am 
Newbie

Joined: Sun Mar 25, 2007 7:14 am
Posts: 1
Hi,
I think you have bad id generation mode in Class mappings..

Instead of:
Quote:
<?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="events.Event" table="EVENTS">
<id name="id" column="EVENT_ID">
<generator class="native"/>
</id>
<property name="date" type="timestamp" column="EVENT_DATE"/>
<property name="title"/>
</class>

</hibernate-mapping>

use:
Quote:
<?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="events.Event" table="EVENTS">
<id name="id" column="EVENT_ID">
<generator class="increment"/>
</id>
<property name="date" type="timestamp" column="EVENT_DATE"/>
<property name="title"/>
</class>

</hibernate-mapping>


You have to post more info about your problem, eg. mappings, use in code etc....

About MS Access, I found commercial driver, google HXTT... For free you can use default Java JDBC-ODBC driver, it connects and communicates, but has wrong SQL syntax, so you need another Dialect.. Next I found SQLServer dialect in Hibernate3.jar, but it does not work too.. :(

PS: I dont understand people from hibernate.. Why they release tutorials which dont work? I was solving "id generation" problem for at least 2 hours, was finding bad syntax etc...


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 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.