-->
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: generating named primary key constraints
PostPosted: Tue Nov 29, 2005 12:44 pm 
Newbie

Joined: Tue Nov 29, 2005 12:28 pm
Posts: 2
Here is my configuration:
- Hibernate 3.1 RC1
- Oracle 9 (org.hibernate.dialect.Oracle9Dialect)
- xdoclet hibernate module 1.2.3

I have xdoclet generating my mapping file, and SchemaExport is creating my SQL DDL from the mapping file. The problem is that I do not see a way to name the primary key constraint. I've searched the web, looked at the docs, searched the forum; no luck.

Is there a way to name the primary key constraint in the hibernate mapping file? And if so, is there a way to express it in xdoclet? (I'd be happy to know it can be done in the mapping file, and then chase down the xdoclet issue separately.)

Here's the xdoclet fragment:

/**
* @hibernate.id generator-class="mepp.MyGenerator"
* @hibernate.column name="subscription_id" length="28" sql-type="char(28)"
*/
String getId()
{
return id;
}

Which produces this mapping:

<id name="id" type="java.lang.String">
<column name="subscription_id" length="28" sql-type="char(28)" />
<generator class="mepp.MyGenerator"/>
</id>

and that, in turn, produces this SQL:

create table subscription (
subscription_id char(28) not null,
primary key (subscription_id)
);

What I really want it to produce is this SQL:

create table subscription (
subscription_id char(28) not null,
constraint pk_subscription_id primary key (subscription_id)
);


Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 29, 2005 6:07 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 7:19 pm
Posts: 2364
Location: Brisbane, Australia
Sorry but no. You can check the DTD to answer alot of these sorts of questions.
http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd

Its also a JIRA request.

http://opensource2.atlassian.com/projects/hibernate/browse/HB-1245


Top
 Profile  
 
 Post subject: how hard is HB-1245 now?
PostPosted: Tue Nov 29, 2005 6:27 pm 
Newbie

Joined: Tue Nov 29, 2005 12:28 pm
Posts: 2
Thanks for the pointers, david.

I see that HB-1245 has not been updated for a year. At the time, the fix was "a bit more work than you might expect." Do you think implementing this functionality would be easier now, on top of hibernate 3?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 29, 2005 7:43 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 7:19 pm
Posts: 2364
Location: Brisbane, Australia
H3 had an awfull lot of enhancements that were "a bit more work than you might expect in it" :-). As EJB 3.0 and advanced ORM feature focus settles I would think this (type) of enhancement is worth revsiting. It might be worth commenting on the JIRA entry and update the request for Hibernate 3.1.x.


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.