-->
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: Mapping question
PostPosted: Fri Mar 05, 2004 9:36 am 
Newbie

Joined: Fri Mar 05, 2004 9:19 am
Posts: 5
Hi there.
I've mapping question. I'm using database which is not done in the proper way.
So eg. table looks like:

Code:
dummy(id, info_a, info_b, info_c, extra_a, extra_b)


I would like to map this database without changing (because of legacy support) in object way.

So I would like to have object "Dummy" and inside it 3 fields
id, info and extra. "Info" and "Extra" will be separate classes. It is easy done such thing in Castor because Castor permits to override get and set method. How to do this in Hibernate? Is it possible? How mapping should looks like? And how to use XDoclet to get mapping be done automatically in that kind of classes.

Eg. classes looks like:

Code:
public Dummy {
   private int id;
   private Extra extra = new Extra();
   private Info info = new Info();

   public int getId() {
      return id;
   }

   public Extra getExtra() {
      return extra;
   }

   public Info getInfo() {
      return info;
   }    

   /* ... setter methods follows here */
   
}

public Extra {   
   private int a;
   private int b;
   private int c;

   public int getA() {
      return a;
   }

   public int getB() {
      return b;
   }

   public int getB() {
      return c;
   }

   /* ... setter methods follows here */
}


Info class is similar to Extra.

Kindly regards.

Sebastian Gil


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 05, 2004 9:53 am 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
Just use a component mapping


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 05, 2004 11:00 am 
Newbie

Joined: Fri Mar 05, 2004 9:19 am
Posts: 5
And how to force XDoclet to generate mapping automatically?

I've added @hibernate.component comment

Code:
/**
* getExtra
* @hibernate.component class="Extra"
* @return MEBUSTCH   
*/
   public Extra getExtra() {
      return extra;
   }


and component tag was generated but nothing is inside. What should I put in comments of class Extra?


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 05, 2004 11:01 am 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
Just normal property XDoclet comments.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 05, 2004 1:55 pm 
Newbie

Joined: Tue Feb 10, 2004 12:03 am
Posts: 16
you also need to have a empty constructor for the bean's


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.