I have a Picture :
public class Picture implements java.io.Serializable { private byte[] picEncoded; private String Name;
Is it possible to move byte[] to another class without creating a physically partitioned table in db? Do I need to use some inheritance strategy?
change
Blob in a separate object:
POJO
public class PictureBlob implements java.io.Serializable { private Integer pictureBlobId; private byte[] blob;
HBM:
<class name="PictureBlob" table="PICTURE"> <id name="pictureBlobId" type="int"> <column length="200" name="PictureID"/> </id> <property name="blob" type="byte[]" insert="false" update="false"> <column name="PicEncoded" not-null="false"/> </property> </class>
Photo:
HBM:
<one-to-one class="PictureBlob" constrained="true" name="pictureBlob" fetch="select"/>
How to insert new photos?
PictureBlob pictureBlob= new PictureBlob(); pictureBlob.setBlob(new byte[]{84,32,22}); Picture p = new Picture(); p.setPictureBlob(pictureBlob); session.save(p);
inserts a record where blob is null.
source share