-->
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.  [ 1 post ] 
Author Message
 Post subject: Setting custom primary key
PostPosted: Thu Dec 01, 2011 5:58 am 
Newbie

Joined: Thu Dec 01, 2011 5:29 am
Posts: 1
Hi,

I was creating an Ant task to do a ORM from a created DataBase with Hibernate Tools. I create annotated classes from database tables with this tool.

Using reversystrategy class I could set my custom names for relations (OneToOne, ManyToOne, etc.) using the method

Code:
public String foreignKeyToCollectionName(String keyname, TableIdentifier fromTable, List fromColumns, TableIdentifier referencedTable, List referencedColumns, boolean uniqueReference)


I could see that this works great.

Now I want to all my primary key will be named "id" in the classes generated. For example, if I have a database table "user" with

Code:
INTEGER myKey PRIMARY_KEY
VARCHAR(50) name


I want to create a class with the properties

Code:
Integer Id;
String name;


Note: I want to make this task general. A priori I don't know how many tables there is in the catalog I want to map, neither the tables names it contains or the primary keys names.


How can I do get this working?

Somebody can help me?


Thanks in advance.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

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.