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.  [ 6 posts ] 
Author Message
 Post subject: reversing, jpa, and custom types??
PostPosted: Wed Sep 20, 2006 9:25 am 
Beginner
Beginner

Joined: Fri Aug 27, 2004 1:59 pm
Posts: 33
I am reversing some classes from tables using JPA annotations. But a few of the columns I need to map into custom types (ie, joda-time). When I add a hibernate-mapping file with the entity specifying only the id and the column with the type mapping, I get some weird errors.

I'm suspecting that the hibernate-mapping is completely overriding some aspects of the annotations as opposed to extending. Can just a few properties of an @Column be overriden? Is there any way to achieve this?


Code:
<hibernate-mapping>

    <class name="com.foliofn.inteliclear.entities.IcCustProfile">
        <id name="id" />
        <property type="org.joda.time.contrib.hibernate.PersistentLocalDate" name="dob"/>
    </class>

</hibernate-mapping>


Code:
@Entity
@Table(name = "cust_profile", uniqueConstraints = { @UniqueConstraint(columnNames = { "acct_no",
        "corr", "office" }) })
public class IcCustProfile implements java.io.Serializable {
    ...
    @Column(name = "dob", unique = false, nullable = true, insertable = true, updatable = true, length = 16)
    public LocalDate getDob() {
        return this.dob;
    }
    ...
}

_________________
-barry
---------------------
polly want-a point?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 20, 2006 10:42 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
that is more a JPA/ejb3 question than a tooling question.

post over in the relevant forum.

(p.s. yes, a hbm.xml overrides any annotations and vice versa. to have overriding use the jpa orm.xml format...even though i think that is also per class)

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 20, 2006 11:46 am 
Beginner
Beginner

Joined: Fri Aug 27, 2004 1:59 pm
Posts: 33
Well, I don't need for these to reversed as JPA, since hibernate JPA will happily work with regular hibernate mapping files. So I would be happy to be able to specify such that the custom the type in the reversed into the generated hbm.xml file

eg:

Code:
<property name="priority">
    <type name="com.mycompany.usertypes.DefaultValueIntegerType">
        <param name="default">0</param>
    </type>
</property>

_________________
-barry
---------------------
polly want-a point?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 20, 2006 11:51 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
well you can enter any type in the typemapping and column mapping in reveng.xml.

type parameters isn't supported yet though.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 20, 2006 12:08 pm 
Beginner
Beginner

Joined: Fri Aug 27, 2004 1:59 pm
Posts: 33
Ok, that's what it looked like. Because if I enter a user type the user type gets used in the reversed pojo, not the actual type that that user type is supporting. And I can't use an additional mapping file because I then get DuplicateMappingException. I guess I'll have to subclass the reversed pojos and add the type annotations manually for now.

thanks!

_________________
-barry
---------------------
polly want-a point?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 20, 2006 12:19 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
"if I enter a user type the user type gets used in the reversed pojo, not the actual type that that user type is supporting"

that only happens if the usertype is actually not on the classpath.

if it is not on the classpath we can't create it and ask what its returnedClass is.

_________________
Max
Don't forget to rate


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 6 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:
cron
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.