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: define table columns without mapping for order
PostPosted: Mon Mar 10, 2008 10:00 am 
Beginner
Beginner

Joined: Wed Jan 16, 2008 4:00 am
Posts: 41
hi all!

Is there a way to define table columns without mapping them directly to a member of a class?

I want to achieve that I can order my collection in the database table without writing an annoying composite-element type and mapping it for each collection.

something like:
Code:
<set name="Col" table="n_m" order-by="order_column">
  <key column="parentId" />
  <column name="order_column" type="string" />
  <many-to-many column="childId" class="type" />
</set>

thx in advance!


Top
 Profile  
 
 Post subject:
PostPosted: Mon Mar 10, 2008 10:20 am 
Regular
Regular

Joined: Wed Jan 25, 2006 1:11 am
Posts: 118
Location: Copenhagen, Denmark
Im not sure i understand you correctly, but as i read it you want to have collections sorted by an unmapped database column, correct?

If this is the case you can add this in your mapping file on the collection using the order-by attribute


Top
 Profile  
 
 Post subject:
PostPosted: Mon Mar 10, 2008 10:47 am 
Beginner
Beginner

Joined: Wed Jan 16, 2008 4:00 am
Posts: 41
thats what I want, yes.

But in addition it would be nice if hibernate can create the tables too. Is there a way to tell hibernate to create this special column?

Your way, which i'm using right now, always forces me to adapt the database after creating it.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Mar 10, 2008 10:56 am 
Regular
Regular

Joined: Wed Jan 25, 2006 1:11 am
Posts: 118
Location: Copenhagen, Denmark
Oh, i don't know if thats possible i suppose schemaexport is only build to create your databaseschema as your mapped properties look like.

One solution would be two map the column and map it to a private field as read-only


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 11, 2008 3:38 am 
Beginner
Beginner

Joined: Wed Jan 16, 2008 4:00 am
Posts: 41
as i see it, i cant even use the order-by attribute if I manually alter the db table.

order-by is not accepted with the <set> element, and by using <bag> i retrieve multiple attributes.


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.