-->
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: Is it possible to override the type?
PostPosted: Wed Jan 30, 2008 6:29 am 
Beginner
Beginner

Joined: Thu Apr 12, 2007 3:26 am
Posts: 35
Location: Germany
Hi!

I'm working with the newest hibernate release.

Consider the following class:
Code:
@Embeddable
public class MyClass {
         @Type(type="one_of_my_user_types")
         @Colum(colum = "my_column")
         private String aField;
         ....
}


Exists there a way to override the type of "aField" in clients of this class (like overriding the column-Attribute with @AttibuteOverrides)? If there exists no solution with annotations, exist there a solution with hibernate mapping files?

The only solution which comes up to my mind is to build severall (in my case: 2) sublasses of MyClass which extends one BaseClass. The base class doesn't have a attribute aField. This attribute is declared in the subclasses with different types:
Code:
public abstract class BaseClass {
       //common fields
}

@Embeddable
public class MyClass1 extends BaseClass {
         @Type(type="one_of_my_user_types")
         @Colum(colum = "my_column")
         private String aField;
         ....
}

@Embeddable
public class MyClass2 extends BaseClass {
         //here we use the standard hibernate type
         @Colum(colum = "my_column")
         private String aField;
         ....
}


Hopefully there exists a better solution
Hoeft


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.