-->
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.  [ 5 posts ] 
Author Message
 Post subject: oracle sequence error!
PostPosted: Tue Sep 20, 2005 3:09 am 
Beginner
Beginner

Joined: Thu Jul 07, 2005 5:17 am
Posts: 30
Hi
hibernate+oracle9i

create sequence persons_seq
start with 1
increment by 1
nominvalue
nomaxvalue
nocycle
nocache

insert into leonyuan.persons(no,name,sex,birday)
values(persons_seq.nextval,'leon','m',to_date('19790312','yyyymmdd'))

person.hbm.xml:
<id
name="no"
type="java.lang.Integer"
column="NO"
>
<generator class="sequence">
<param name="sequence">persons_seq</param>
</generator>
</id>

test:
Query query = session.createQuery("from Person i");

error:
net.sf.hibernate.MappingException: could not instantiate id generator


Top
 Profile  
 
 Post subject:
PostPosted: Tue Sep 20, 2005 9:56 pm 
Senior
Senior

Joined: Wed Jul 13, 2005 4:31 pm
Posts: 142
Location: Seattle, WA
This works
Code:
    <id
        name="id"
        type="java.lang.Long"
        column="ID"
    >
        <generator class="native">
         <param name="sequence">ID_SEQ</param>
      </generator>
    </id>


The only difference is the class is native and datatype is Long. I don't see why that should be a problem though.
Also, make sure your dialect is correctly set.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Sep 20, 2005 11:32 pm 
Beginner
Beginner

Joined: Thu Jul 07, 2005 5:17 am
Posts: 30
I try just what you said,it's ok,but why class="sequence" cannot work?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Sep 20, 2005 11:33 pm 
Beginner
Beginner

Joined: Thu Jul 07, 2005 5:17 am
Posts: 30
is a bug or sth else?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 21, 2005 12:45 am 
Newbie

Joined: Sun Sep 11, 2005 11:36 pm
Posts: 6
Hi
You cant have Class and Param name same, u can have id and value same or property name and bean name same but cant have the class name and the Param same...
i think u got ur answer....


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