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: Generic binary type
PostPosted: Thu Nov 20, 2008 5:17 pm 
Newbie

Joined: Thu Nov 20, 2008 5:01 pm
Posts: 1
Hibernate version: 2.0.0.3002

Hi,

This may be a stupid question but I am just wondering if it is possible.

I would like to save certain properties in a generic way, i.e. stream them from their .Net types to and from binary in the DB.
I was hoping to do this from my real object classes rather than having a transalation object with a byte array that I'd have to stream into before saving.

The List<Guid> is just a test the real objects are much more complex.

I have the class and mapping below, I essentially want something to replace to BinaryBlob in the mapping if it is possible or any other way to do the same thing.

Thanks, Vin

Mapping file:
Code:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" namespace="TestObjects" assembly="TestObjects" >
  <class name="TestObjects.Class1, TestObjects" table="TestObjectsClass1" >
    <id name="I" column="I"  access="field.camelcase-underscore" type="int" >
      <generator class="assigned" />
    </id>
    <version name="Version" type="Timestamp" unsaved-value="01/01/1753 00:00:00"/>
    <property name="BinaryTest" column="BinaryTest" type="BinaryBlob" />
    <property name="S" column="S" type="string" />
  </class>
</hibernate-mapping>


Class file:
Code:
namespace TestObjects
{
  [Cacheable, Serializable]
  public class Class1 : BaseClass1
  {
    private string _s;
    DateTime _version;
    List<Guid> _binaryTest;

    public virtual List<Guid> BinaryTest
    {
        get { return _binaryTest; }
        set { _binaryTest = value; }
    }

    public virtual string S
    {
      get { return _s; }
      set { _s = value; }
    }

    public virtual DateTime Version
    {
      get { return _version; }
      set { _version = value; }
    }
  }
}


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.