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.  [ 8 posts ] 
Author Message
 Post subject: SchemaExport StringClob+MySQL = VARCHAR(255)
PostPosted: Thu Jan 04, 2007 5:51 pm 
Newbie

Joined: Thu Jan 04, 2007 3:56 pm
Posts: 11
When running a schemaexport on mapping of the type StringClob using the MySql(5) dialect I get the sql type VARCHAR(255) instead of LONGTEXT (mapping and output sql below).

Exporting with sql server 2000/2005 dialect gives ntext/nvarchar(max) as expected.

Any ideas? Is this a bug?

Thank you.

/Cristian



hbm mapping:
Code:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2">
   <class name="N2.Details.ContentDetail,N2" table="n2Detail" lazy="true">
      <cache usage="nonstrict-read-write" />

      <id name="ID" column="ID" type="Int32" unsaved-value="0">
         <generator class="native"/>
      </id>
      <discriminator column="Type" type="String" />

      <many-to-one name="Item" column="ItemID" class="N2.ContentItem,N2" not-null="true" />
      <many-to-one name="Collection" column="DetailCollectionID" class="N2.Details.DetailCollection,N2" />

      <property name="Name" type="String" length="50" />
      
      <subclass name="N2.Details.BooleanDetail,N2" discriminator-value="Bool">
         <property name="BoolValue" type="Boolean" />
      </subclass>
      
      <subclass name="N2.Details.IntegerDetail,N2" discriminator-value="Int">
         <property name="IntValue" type="Int32" />
      </subclass>

      <subclass name="N2.Details.LinkDetail,N2" discriminator-value="Link">
         <many-to-one name="LinkedItem" column="LinkValue" class="N2.ContentItem,N2" />
      </subclass>

      <subclass name="N2.Details.DoubleDetail,N2" discriminator-value="Double">
         <property name="DoubleValue" type="Double" />
      </subclass>
      
      <subclass name="N2.Details.DateTimeDetail,N2" discriminator-value="DateTime">
         <property name="DateTimeValue" type="DateTime" />
      </subclass>
      
      <subclass name="N2.Details.StringDetail,N2" discriminator-value="String">
         <property name="StringValue" type="StringClob" />
      </subclass>
      
      <subclass name="N2.Details.ObjectDetail,N2" discriminator-value="Object">
         <property name="Value" type="Serializable" length="2147483647" />
      </subclass>
   </class>
</hibernate-mapping>





Resulting output (some irrelevant constraints snipped):
Code:
create table n2Detail (
  ID INTEGER NOT NULL AUTO_INCREMENT,
   Type VARCHAR(255) not null,
   ItemID INTEGER not null,
   DetailCollectionID INTEGER,
   Name VARCHAR(50),
   BoolValue TINYINT(1),
   IntValue INTEGER,
   LinkValue INTEGER,
   DoubleValue DOUBLE,
   DateTimeValue DATETIME,
   StringValue VARCHAR(255),
   Value LONGBLOB,
   primary key (ID)
)


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 27, 2008 10:40 am 
Newbie

Joined: Thu Mar 27, 2008 10:36 am
Posts: 1
Hello, did you solve this problem?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 03, 2008 5:24 pm 
Newbie

Joined: Thu Jan 04, 2007 3:56 pm
Posts: 11
Not the way I was hoping for (with just one hbm xml file). I solved it by allowing change to another mapping file.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Apr 04, 2008 7:17 am 
Beginner
Beginner

Joined: Fri Aug 10, 2007 3:34 am
Posts: 44
change
<property name="StringValue" type="StringClob" />
to
<property name="StringValue" type="StringClob">
<column sql-type="longtext"/>
</property>


Top
 Profile  
 
 Post subject:
PostPosted: Sat Apr 05, 2008 6:43 pm 
Newbie

Joined: Thu Jan 04, 2007 3:56 pm
Posts: 11
Matrasinator wrote:
change
<property name="StringValue" type="StringClob" />
to
<property name="StringValue" type="StringClob">
<column sql-type="longtext"/>
</property>


Hi,

I just tried it against sql server 2005 and the resulting sql is

StringValue longtext null,

For that case I was hoping for nvarchar(max). My goal is having a single mapping file that works without change for various dialects. Do you have any other suggestions?

Thanks/Cristian


Top
 Profile  
 
 Post subject:
PostPosted: Mon Apr 07, 2008 3:54 am 
Beginner
Beginner

Joined: Fri Aug 10, 2007 3:34 am
Posts: 44
not any that i know off... you could do it manually....
it's weird that the schema export tool ignores the "sql-type"
maybe with NHibernate 2.0 schema export works better..

Regards, Christian


Top
 Profile  
 
 Post subject:
PostPosted: Mon Apr 07, 2008 9:04 am 
Newbie

Joined: Thu Jan 04, 2007 3:56 pm
Posts: 11
Oh, the sql-typ isn't ignored. It's parsed quite literally.


Top
 Profile  
 
 Post subject: Re: SchemaExport StringClob+MySQL = VARCHAR(255)
PostPosted: Mon May 26, 2008 6:15 am 
Newbie

Joined: Mon May 26, 2008 6:09 am
Posts: 1
libardo wrote:
When running a schemaexport on mapping of the type StringClob using the MySql(5) dialect I get the sql type VARCHAR(255) instead of LONGTEXT (mapping and output sql below).

Exporting with sql server 2000/2005 dialect gives ntext/nvarchar(max) as expected.



Huh ?
It doesn't work on 2005 dialect !

I use:
Code:
<property name="Comment" column="Comment" type="StringClob" />


And SchemaExport returns:
Code:
Comment NVARCHAR(255) null


Am I missing something or is this a bug ?


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