-->
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.  [ 7 posts ] 
Author Message
 Post subject: Urgent help needed:
PostPosted: Wed Sep 17, 2003 3:56 pm 
Newbie

Joined: Tue Sep 16, 2003 4:45 pm
Posts: 14
Hi
I am getting the following error on compiling the program

net.sf.hibernate.MappingException: Dialect does not support native key generation


The configuration of hibernate.properties file is given below
---------------------------------------------------------------
hibernate.dialect net.sf.hibernate.dialect.MySQLDialect
hibernate.connection.driver_class org.gjt.mm.mysql.Driver
#hibernate.connection.driver_class com.mysql.jdbc.Driver
hibernate.connection.url jdbc:mysql://localhost:3306/testdb
hibernate.connection.username root
hibernate.connection.password abx01
-----------------------------------------------
The configuration of the entity file is given below
------------------------------------------------
<class name="eg.entity.Merchant"
table="Merchant">

<id name="merchantid"
column="merchantid"
unsaved-value="-1">
<generator class="identity"/>
</id>

<property name="merchantname"
column="merchantname"
not-null="true"
unique="true"
/>
<property name="merchantwebsite"
column="merchantwebsite"
not-null="false"
unique="false"
/>


</class>
---------------------------------------------------------
Thanks in advance for all the replies.


Top
 Profile  
 
 Post subject: Re: Urgent help needed:
PostPosted: Wed Sep 17, 2003 4:07 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
rc wrote:
Hi
I am getting the following error on compiling the program

net.sf.hibernate.MappingException: Dialect does not support native key generation



eh - the error is standing right there in the exception!
The dialect you have chosen (MySql) does not support native key generation - use another database or change key generation strategy ,)

/max

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject: 5.1.4.1 says it is possible
PostPosted: Wed Dec 10, 2003 7:02 pm 
Beginner
Beginner

Joined: Wed Dec 10, 2003 6:58 pm
Posts: 40
Location: Stockholm, Sweden
Hi there,

I have got the same problem as stated above. What surprises me a bit is that u say it is not supported for MySQL dialect. In chapter 5.1.4.1 of the hibernate reference, http://www.hibernate.org/hib_docs/reference/html/or-mapping.html,
says it is.

identity
supports identity columns in DB2, MySQL, MS SQL Server, Sybase and HypersonicSQL. The returned identifier is of type long, short or int.

What am I missing here?

Best regards
Lasse


Top
 Profile  
 
 Post subject:
PostPosted: Wed Dec 10, 2003 7:09 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
Max is mistaken. MySQL supports identity/native ids. More likely your properties file is not being found.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Dec 11, 2003 3:49 am 
Beginner
Beginner

Joined: Wed Dec 10, 2003 6:58 pm
Posts: 40
Location: Stockholm, Sweden
gavin wrote:
Max is mistaken. MySQL supports identity/native ids. More likely your properties file is not being found.


my mapping file looks like this:
--------------------------------------------------------------------------------
Code:
<hibernate-mapping>

    <class name="Cat" table="CAT">

    <id name="id" type="long" column="CAT_ID" unsaved-value="0">
        <generator class="identity"/>
    </id>

        <!-- A cat has to have a name, but it shouldn' be too long. -->
        <property name="name">
            <column name="NAME" sql-type="varchar(16)" not-null="true"/>
        </property>

        <property name="sex"/>

        <property name="weight"/>

    </class>

</hibernate-mapping>



my properties file looks like this
-------------------------------------
Code:
<hibernate-configuration>

    <session-factory>

        <property name="connection.datasource">java:/MySqlDS</property>
        <property name="show_sql">false</property>
        <property name="dialect">hibernate.dialect net.sf.hibernate.dialect.MySQLDialect</property>

        <!-- Mapping files -->
        <mapping resource="Cat.hbm.xml"/>

    </session-factory>

</hibernate-configuration>



You suggested that the properties file (in my case hibernate.cfg.xml) could not be found. However, when I rename or remove the config file I get
HTTP ERROR: 500 /hibernate.cfg.xml not found

So, finding the config file was not the problem. I am really struggling with this. It feels like this should be a fairly common problem since I am not doing anything complicated.

By the way, I got it working with
generator class="uuid.hex" ... the problem is that I have already started with auto_incremented ids in my tables so I really would like to continue on that path, which I should be able to with generator="identity".

Best regards

Lasse
[/code]


Top
 Profile  
 
 Post subject:
PostPosted: Thu Dec 11, 2003 4:01 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
Well, the problem is pretty obvious:

Code:
<property name="dialect">hibernate.dialect net.sf.hibernate.dialect.MySQLDialect</property>


clearly should be:

<property name="dialect">net.sf.hibernate.dialect.MySQLDialect</property>


Top
 Profile  
 
 Post subject:
PostPosted: Thu Dec 11, 2003 5:32 am 
Beginner
Beginner

Joined: Wed Dec 10, 2003 6:58 pm
Posts: 40
Location: Stockholm, Sweden
It worked. Thanx a looooooooot ... The mistake I made was to copy the dialect part directly from the properties file.

Best regards

Lasse


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