-->
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: How do I embed non-annotated legacy components?
PostPosted: Wed Jan 10, 2007 3:46 pm 
Newbie

Joined: Fri Jan 05, 2007 4:36 pm
Posts: 3
Hi,

I'm trying to build an Hibernate/EJB 3.0 application (application.jar) that depends on a non-EJB library (framework.jar), and I'd like to use @Embedded components however the legacy components cannot be modified or marked as @Embeddable.

Is there a way to do this with Hibernate Annotations?

Example: application.jar
Code:
@Entity
public class Profile {
     @Embedded
     private PaymentInstrument instrument;

     // getters and setters omitted
}


Example: framework.jar
Code:
public class PaymentInstrument {
     private String instrumentNumber;
     private String routingNumber;

     // getters and setters omitted
}


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jan 10, 2007 4:26 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
yes, your mapping will work. If you want to override the column name you can also use @AttributeOverride(s) where @Embedded is

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 11, 2007 11:26 pm 
Newbie

Joined: Fri Jan 05, 2007 4:36 pm
Posts: 3
Hi, there,

Thanks very much for your reply, that works great!

My next problem is on how to persist custom types that are part of legacy components.

For example, if I had the above code sample with the following modification to "PaymentInstrument":

Example: framework.jar
Code:
public class PaymentInstrument {
     private String instrumentNumber;
     private String routingNumber;

     private PaymentChannel channel;

     // getters and setters omitted
}


where PaymentChannel is:
Code:
public class PaymentChannel {
     private int type;
     private String description;

     // remaining code omitted
}


Normally, I would demark the PaymentChannel with @Type and use a custom implementation of org.hibernate.usertype.UserType, but in this case, I have no access to the legacy class. Any suggestions on how to persist this custom type in the database?

Thanks for your time,
Tan


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 12, 2007 8:07 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
you can't, you'll have to rely on an hm.xml file to map this entity

_________________
Emmanuel


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.