-->
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.  [ 3 posts ] 
Author Message
 Post subject: How to map 1 table to multiple classes?
PostPosted: Fri Feb 17, 2012 11:55 am 
Newbie

Joined: Fri Feb 17, 2012 10:19 am
Posts: 2
I have a table named Person. Mapped class looks something like this:
Code:
public class Person implements java.io.Serializable {
    private Integer personId;
    private String name;
    private Long age;
    private byte[] photo;
    //getters setters omitted

How to move
Code:
byte[] photo
to a separate class that has 1-to-1 association with Person. I want to do this so i could lazy load blob on demand (my db doesn't support lazy loading properties).

currently i have:
Person class hbm:
Code:
<one-to-one class="Photo" name="photo" constrained="true" fetch="select"  />

Photo:
Code:
<class name="Photo" table="PERSON" polymorphism="explicit">
   
    <id name="photoId" type="int">
      <column length="200" name="PersonID"/> 
      <generator class="increment"/>
    </id>
 
    <property name="blob" type="byte[]">
      <column name="Photo" not-null="false"/>
    </property>


I can select existing Person records with this, but i cant insert new - Photo value is null in db. Please give some advice.


Top
 Profile  
 
 Post subject: Re: How to map 1 table to multiple classes?
PostPosted: Mon Feb 20, 2012 2:56 am 
Newbie

Joined: Fri Feb 17, 2012 10:19 am
Posts: 2
Anyone?


Top
 Profile  
 
 Post subject: Re: How to map 1 table to multiple classes?
PostPosted: Tue Feb 21, 2012 1:06 am 
Newbie

Joined: Tue Feb 21, 2012 12:57 am
Posts: 5
That's right?

_________________
nostale gold


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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.