-->
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.  [ 10 posts ] 
Author Message
 Post subject: Schema Generatiaon
PostPosted: Wed Jun 08, 2005 6:26 pm 
Regular
Regular

Joined: Tue Nov 09, 2004 5:15 pm
Posts: 100
Hi All,

We just started a project which will use Hibernate 3.0 for persistence. Currently we are using the annotations to create the schema using hbm2ddl.auto property. I understand that this is NOT meant for production. In our organization, we need to provide the DDL for each and every table separately that include schema, table space indexes etc. In that case, using SchemaExport will i be able to generate a .sql file for each Entity class? Also, i noticed that SchemaExport gives some NUMBER for constraints and our requirement is to have a name for that. Is there a way i could change that?


Thanks in advance!


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jun 08, 2005 11:48 pm 
Newbie

Joined: Wed Aug 18, 2004 8:44 am
Posts: 12
You can generate the schema using SchemaExport, them dump your schema to a .sql file. After that you're free to edit the file and change the constraints names.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jun 09, 2005 1:34 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
you can name all constraints AFAIK. (e.g. via foreign-key atttribute)

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jul 24, 2005 5:07 pm 
Regular
Regular

Joined: Tue Nov 09, 2004 5:15 pm
Posts: 100
Hi max,

In the hibernate generated DDL, we've a table called WORKGROUP.

create table WORKGROUP (
id number(19,0) not null,
NAME varchar2(255),
IS_ACTIVE number(1,0),
DESCRIPTION varchar2(255),
CREATED_BY_ID varchar2(255),
ESCALATION_FLAG number(1,0),
P0_PREFERENCE number(1,0),
P1_PREFERENCE number(1,0),
P2_PREFERENCE number(1,0),
P3_PREFERENCE number(1,0),
EMAIL_PAGER varchar2(255),
APPLICATION_ESCALATION_TEAM_ID number(19,0),
primary key (id)
);

alter table WORK_GROUP
add constraint FK31D2CFB1362EF931
foreign key (APPLICATION_ESCALATION_TEAM_ID)
references APPLICATION_ESCALATION_TEAM;

SchemaExport generates some number for constraint. I'm not sure how we could change that to a user defined "NAME"


We are using annoations.

Please advice.


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jul 24, 2005 5:26 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
grep the DTD for foreign-key attribute


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jul 24, 2005 6:00 pm 
Regular
Regular

Joined: Tue Nov 09, 2004 5:15 pm
Posts: 100
Gavin, i just saw this post as well http://forum.hibernate.org/viewtopic.ph ... +manytoone


But i don't see any such equivalent for @ManyToOne annotation.


For now, in the WorkGroup class which has One to many relationship with the applicationEscalationTeam, we've defined the annotation as follows.

@ManyToOne
@JoinColumn(name="APPLICATION_ESCALATION_TEAM_ID", insertable = false, updatable = false)

I don't see any way to define "foreign-key" attribute for this.

I did check the ManyToOne.class in the eclipse and it doesn't seem to have any foreignKey method too. Could you please let me know how do i define this?

Thanks in advance!


Top
 Profile  
 
 Post subject:
PostPosted: Tue Aug 16, 2005 6:27 pm 
Regular
Regular

Joined: Tue Nov 09, 2004 5:15 pm
Posts: 100
Could someone please tell me how to give a valid name for the constraint name in the schemaexport generated schema?

Here's what the schema export generates.



Code:
alter table WORKGROUP
    add constraint FKE78801EE54B7DBF8
    foreign key (ESCALATION_TEAM_ID)
    references ESCALATION_TEAM;


I would like to give a valid name for the constraint.


As Gavin mentioned, i couldn't find any equivalent for foreign-key using hibernate annotations.

Thanks for any help in advance!


Top
 Profile  
 
 Post subject:
PostPosted: Tue Aug 16, 2005 9:46 pm 
Expert
Expert

Joined: Thu Dec 04, 2003 12:36 pm
Posts: 275
Location: Bielefeld, Germany
It is currently not supported using Hibernate Annotations.

See:
http://forum.hibernate.org/viewtopic.php?t=946026

You'll have to stick to XML Mappings or create the schema on your own.

Best regards
Sven

_________________
Please don't forget to give credit, if this posting helped to solve your problem.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Aug 16, 2005 10:23 pm 
Regular
Regular

Joined: Tue Nov 09, 2004 5:15 pm
Posts: 100
Thanks Sven.

I hope this feature is implemented soon!


Top
 Profile  
 
 Post subject:
PostPosted: Tue Aug 16, 2005 10:37 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
Me too... provide a patch :-D

_________________
Emmanuel


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