-->
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.  [ 4 posts ] 
Author Message
 Post subject: Cannot control BLOB length for DB2 dialect
PostPosted: Tue Mar 12, 2013 1:19 pm 
Newbie

Joined: Wed Dec 05, 2012 5:12 am
Posts: 2
I'm trying to control the length of a BLOB column using the DB2 schema. My final goal is to have hibernatetool generate the SQL file for a 10M long BLOB column, and given the files pasted down here I always get a blob(255). What am I doing wrong?

build.xml (omitted less relevant parts):
Code:
<taskdef name="hibernatetool"
         classname="org.hibernate.tool.ant.HibernateToolTask"
         classpathref="toolslib" />

<target name="default">
<hibernatetool destdir="./generated">
<classpath>
  <path location="." />
  <path location="./classes" />
</classpath>

<configuration configurationfile="hibernate.cfg.xml"/>
<hbm2ddl export="false" outputfilename="sql.ddl"/>
</hibernatetool>


hibernate.cfg.xml:
Code:
<hibernate-configuration>
<session-factory>
  <property name="dialect">org.hibernate.dialect.DB2Dialect</property>
  <!-- Mapping files -->
  <mapping resource="DbContentStream.mapping.xml"/>
</session-factory>
</hibernate-configuration>


DbStreamImpl mapping:
Code:
<hibernate-mapping>

    <class name="DbContentStreamImpl"
           table="CONTENT_STREAM">
        <cache usage="read-write"/>
        <id name="id" type="java.lang.Long" access="field">
            <column name="id"/>
            <generator class="native">
            </generator>
        </id>

        <property name="content" type="blob" length="10485760">
            <column name="CONTENT"/>
        </property>
    </class>

</hibernate-mapping>


the resulting SQL file is (notice the length of the blob field):
Code:
create table CONTENT_STREAM (id bigint generated by default as identity, CONTENT blob(255), primary key (id));


Thanks in advance for any help


Top
 Profile  
 
 Post subject: Re: Cannot control BLOB length for DB2 dialect
PostPosted: Tue Mar 12, 2013 2:28 pm 
Newbie

Joined: Wed Dec 05, 2012 5:12 am
Posts: 2
Answering my own question, moving the length to the column fixes my problem:

DbStreamImpl mapping:
Code:
<hibernate-mapping>

    <class name="DbContentStreamImpl"
           table="CONTENT_STREAM">
        <cache usage="read-write"/>
        <id name="id" type="java.lang.Long" access="field">
            <column name="id"/>
            <generator class="native">
            </generator>
        </id>

        <property name="content" type="blob">
            <column name="CONTENT"  length="10485760"/>
        </property>
    </class>

</hibernate-mapping>


Top
 Profile  
 
 Post subject: Re: Cannot control BLOB length for DB2 dialect
PostPosted: Wed Mar 13, 2013 3:16 am 
Newbie

Joined: Wed Mar 13, 2013 3:06 am
Posts: 1
Location: Chenddu
This is so hard.


Top
 Profile  
 
 Post subject: Re: Cannot control BLOB length for DB2 dialect
PostPosted: Mon Apr 01, 2013 7:02 am 
Newbie

Joined: Mon Apr 01, 2013 6:58 am
Posts: 1
I don't have much knowledge about it but my friend is an expert in these field and runs a company also, so you can contact him and get the solution for your problem.
http://www.coffy.com


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