-->
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: hibernate_unique_key' doesn't exist
PostPosted: Wed May 12, 2004 9:57 am 
Newbie

Joined: Wed May 12, 2004 8:14 am
Posts: 4
Location: Gaborone
I'm using spring 1.01 hibernate 2.1.2 and mysql. I'm trying to run unit tests on my DAOs(load/saving/deleting) which are going well except for saving "native" id-generated objects. Saving "assigned" id-generated objects works well.

For the tests i prepopulate the table with data and even supply ids for "natively" created ids.Here is a sample of sql to populate db. [librarydemo].

Code:
create table reservations (
   id BIGINT NOT NULL AUTO_INCREMENT,
   book_id VARCHAR(25),
   date_made DATE,
   member_id VARCHAR(20),
   remarks VARCHAR(255),
   limit_in_days INTEGER,
   primary key (id)
);


Code:
insert into reservations values (1,'1-86100-784-1','2004-04-25','2004-1238','1st reserver',25);
insert into reservations values (2,'1-861002-23-8','2004-04-26','2004-1243','1st reserver',25);

The code snippets in java are as follows

Code:
@hibernate.class table="reservations"

public class Reservation
{
    /*
     *    @hibernate.id
     *             name="id"
     *             type="long"
     *             column="id"
     *             unsaved-value="-1"
     *             generator-class="native"
     */
    public Long getId()
    {
        return this.id;
    }
.  . . .
}



Top
 Profile  
 
 Post subject:
PostPosted: Wed May 12, 2004 10:34 am 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
Have you set the correct dialect?


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 12, 2004 10:53 am 
Newbie

Joined: Wed May 12, 2004 8:14 am
Posts: 4
Location: Gaborone
I should think so because i have a total of 36 tests, 33 of which have run succesfully and only 3 which have given me this stack trace. All the 3 are supposed to persist new objects to db. They use "native" generator class.

This is what i use
Code:
<prop key="hibernate.dialect">net.sf.hibernate.dialect.MYSQLDialect</prop>


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 12, 2004 11:02 am 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
It is "net.sf.hibernate.dialect.MySQLDialect" ...


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 12, 2004 11:15 am 
Newbie

Joined: Wed May 12, 2004 8:14 am
Posts: 4
Location: Gaborone
ouch!! Thanks a lot. It now works!!
So young a mistake and so very big a stack trace :)


Top
 Profile  
 
 Post subject: same error message, different cause?
PostPosted: Wed Oct 06, 2004 11:53 am 
Newbie

Joined: Mon Sep 27, 2004 7:49 pm
Posts: 3
I get the exact same error message as metaele.

I have objects set up essentially the same way, with the id generator set to "native", and i also get the "hibernate_unique_key" doesn't exist.

Unfortunately, i checked and i am already using the correct dialect, which puts me back to square 1. What other problems could cause this error?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Oct 07, 2004 2:23 am 
Expert
Expert

Joined: Thu Jan 29, 2004 2:31 am
Posts: 362
Location: Switzerland, Bern
Maybe http://forum.hibernate.org/viewtopic.php?t=935050
helps.

Ernst


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.