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.  [ 4 posts ] 
Author Message
 Post subject: is it possible to name the generated PK in schema export?
PostPosted: Fri Mar 30, 2007 11:24 am 
Newbie

Joined: Sat Mar 10, 2007 5:51 pm
Posts: 3
Hibernate version: 322

Name and version of the database you are using:
oracle9i

The generated SQL (show_sql=true):
create table MESSAGE (MESSAGE_ID number(19,0) not null, MESSAGE_TEXT varchar2(255), NEXT_MESSAGE_ID number(19,0), primary key (MESSAGE_ID))

this way oracle assigns the PK a name from its internal name sequense (like SYS_C007385). Is it possible to set it a meaningful name?

I'd like to be able to configure H to generate:

create table MESSAGE (MESSAGE_ID number(19,0) not null, MESSAGE_TEXT varchar2(255), NEXT_MESSAGE_ID number(19,0);

ALTER TABLE MESSAGE ADD CONSTRAINT PK_MESSAGE
PRIMARY KEY (
MESSAGE_ID
);


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 30, 2007 12:14 pm 
Expert
Expert

Joined: Tue Dec 28, 2004 7:02 am
Posts: 573
Location: Toulouse, France
I'm not sure, try unique-key attribute on the column tag.

_________________
Baptiste
PS : please don't forget to give credits below if you found this answer useful :)


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 30, 2007 2:22 pm 
Newbie

Joined: Fri Mar 30, 2007 8:19 am
Posts: 6
Wy didn't you post your mapping file? Let us take a look to see if you are doing something weird.


Top
 Profile  
 
 Post subject:
PostPosted: Sun Apr 01, 2007 2:54 am 
Newbie

Joined: Sat Mar 10, 2007 5:51 pm
Posts: 3
palako wrote:
Wy didn't you post your mapping file? Let us take a look to see if you are doing something weird.


I thought it was unnecessary, since it is copied from the H book. AFAIK the only change is different pacckage

<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class name="prototype.Message" table="MESSAGE">
<id name="id" column="MESSAGE_ID">
<generator class="increment"/>
</id>

<property name="text" column="MESSAGE_TEXT"/>
<many-to-one name="nextMessage" cascade="all" column="NEXT_MESSAGE_ID"
foreign-key="FK_NEXT_MESSAGE"/>
</class>
</hibernate-mapping>


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