-->
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.  [ 6 posts ] 
Author Message
 Post subject: Tutorial app gives errors.
PostPosted: Tue Dec 08, 2009 8:14 am 
Newbie

Joined: Tue Dec 08, 2009 8:03 am
Posts: 6
Hi. I'm a hibernate beginner so sorry for tedious questions.
I tried web tutorial from hibernate reference (1.1. Part 1 -...) and it gave me some error logging.

This is what it complains about, even though expected database entries were made (when calling main() method from EventManager):
Code:
1155 [main] ERROR org.hibernate.tool.hbm2ddl.SchemaExport - Unsuccessful: create table EVENTS (EVENT_ID bigint generated by default as identity (start with 1), EVENT_DATE timestamp, EVENT_TITLE varchar(255), primary key (EVENT_ID))
1155 [main] ERROR org.hibernate.tool.hbm2ddl.SchemaExport - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'generated by default as identity (start with 1), EVENT_DATE timestamp, EVENT_TIT' at line 1
1155 [main] INFO org.hibernate.tool.hbm2ddl.SchemaExport - schema export complete
Hibernate: insert into EVENTS (EVENT_ID, EVENT_DATE, EVENT_TITLE) values (null, ?, ?)


1. It hibernate generates a query for creating tables which as I can see is incorrect.
2. It tries to proceed with INSERT query, which is also said to be incorrect (though it really inserts values).

Can anyone tell how I can resolve this issues?

_________________
We keep moving forward, opening new doors, and doing new things, because we're curious and curiosity keeps leading us down new paths.


Top
 Profile  
 
 Post subject: Re: Tutorial app gives errors.
PostPosted: Wed Dec 09, 2009 6:02 am 
Newbie

Joined: Tue Dec 08, 2009 8:03 am
Posts: 6
Using:

hibernate-distribution-3.3.2.GA
slf4j-1.5.8
servlet-api-2.5
mysql 5.1

Is there someone who is able to deal with tutorial application? :)

_________________
We keep moving forward, opening new doors, and doing new things, because we're curious and curiosity keeps leading us down new paths.


Top
 Profile  
 
 Post subject: Re: Tutorial app gives errors.
PostPosted: Wed Dec 09, 2009 6:30 am 
Regular
Regular

Joined: Mon Aug 07, 2006 5:07 am
Posts: 56
What is your hibernate configuration and your hibernate dialect?


Top
 Profile  
 
 Post subject: Re: Tutorial app gives errors.
PostPosted: Wed Dec 09, 2009 7:05 am 
Newbie

Joined: Tue Dec 08, 2009 8:03 am
Posts: 6
Here is how my *.xml looks:

hibernate.cfg.xml
Code:
<?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>

        <!-- Database connection settings -->
        <property name="connection.driver_class">com.mysql.jdbc.Driver</property>
        <property name="connection.url">jdbc:mysql://127.0.0.1:3306/tutorials</property>
        <property name="connection.username">tutorials</property>
        <property name="connection.password">tutorials</property>

        <!-- JDBC connection pool (use the built-in) -->
        <property name="connection.pool_size">1</property>

        <!-- SQL dialect -->
        <property name="dialect">org.hibernate.dialect.HSQLDialect</property>

        <!-- Enable Hibernate's current session context -->
        <property name="current_session_context_class">org.hibernate.context.ManagedSessionContext</property>

        <!-- Enable Hibernate's automatic session context management -->
      <property name="current_session_context_class">thread</property>
      
      <!-- Disable the second-level cache -->
      <property name="cache.provider_class">org.hibernate.cache.NoCacheProvider</property>
      
      <!-- Echo all executed SQL to stdout -->
      <property name="show_sql">true</property>
      
      <!-- Drop and re-create the database schema on startup -->
      <property name="hbm2ddl.auto">create</property>

        <mapping resource="org/hibernate/tutorial/domain/Event.hbm.xml"/>

    </session-factory>

</hibernate-configuration>


Event.hbm.xml:
Code:
<?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 package="org.hibernate.tutorial.domain">

    <class name="Event" table="EVENTS">
        <id name="id" column="EVENT_ID">
            <generator class="native"/>
        </id>
        <property name="date" type="timestamp" column="EVENT_DATE"/>
        <property name="title" column="EVENT_TITLE"/>
    </class>

</hibernate-mapping>


It is provided in distribution tutorials a bit modified in accordance with pdf referance (provided with distribution) 1.1. Part 1 - ....

_________________
We keep moving forward, opening new doors, and doing new things, because we're curious and curiosity keeps leading us down new paths.


Top
 Profile  
 
 Post subject: Re: Tutorial app gives errors.
PostPosted: Thu Dec 10, 2009 3:06 am 
Senior
Senior

Joined: Tue Oct 28, 2008 10:39 am
Posts: 196
That's wrong: <property name="dialect">org.hibernate.dialect.HSQLDialect</property>


Top
 Profile  
 
 Post subject: Re: Tutorial app gives errors.
PostPosted: Thu Dec 10, 2009 9:03 am 
Newbie

Joined: Tue Dec 08, 2009 8:03 am
Posts: 6
Yep, that's totally wrong.
Thanks, problem solved.

_________________
We keep moving forward, opening new doors, and doing new things, because we're curious and curiosity keeps leading us down new paths.


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