-->
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.  [ 5 posts ] 
Author Message
 Post subject: string datatype automatically mapped to varchar(255)
PostPosted: Tue Nov 04, 2003 10:18 am 
Newbie

Joined: Tue Nov 04, 2003 10:08 am
Posts: 3
hello,
i'm just getting up to speed with hibernate and have been writing some test code but have run into an issue i can't seem to find any documentation on.

here's the mapping for my (ridiculously simple) Resource test class.
Code:
<hibernate-mapping>
  <class name="Resource" table="Resources" discriminator-value="R">
    <id name="resourceId" column="resourceId" type="int">
      <generator class="hilo"/>
    </id>
    <property name="creationDate" type="long" not-null="true"/>
    <property name="categoryId" not-null="true" type="int"/>
    <property name="creatorId" not-null="true" type="int"/>
    <property name="title" not-null="true" type="string"/>
    <property name="description" not-null="true" type="string"/>
    <property name="content" type="string"/>
  </class>
</hibernate-mapping>


in my test code, i call the following two methods to initialize hibernate:

Code:
 
public void configure() throws HibernateException
{
  sessionFactory = new Configuration()
      .addClass(Resource.class)
      .buildSessionFactory();
}

public void exportTables() throws HibernateException
{
  Configuration cfg = new Configuration()
      .addClass(Resource.class);
  new SchemaExport(cfg).create(true, true);
}


this has the effect of dropping the existing tables and recreating them which isn't a problem (yet). -however-, the data type for the 'content' member is String (and should be able to handle Strings of any length (> 255)) but during the table recreation, it gets created as a varchar(255). this holds true for all the String data types.

since the 'content' can conceivably be extremely large, i was hoping for a mapping to 'text' or 'bigtext' or something along those lines.

any ideas how i can get hibernate to follow my conception of the String java type to support extremely large string content? also, so i don't write back too quickly, if i want to prevent hibernate from touching existing production tables, how do i disable the dropping/recreating?

thanks in advance for your help!
jason


Top
 Profile  
 
 Post subject: follow-up
PostPosted: Tue Nov 04, 2003 10:48 am 
Newbie

Joined: Tue Nov 04, 2003 10:08 am
Posts: 3
btw, i am using mysql 4.0.16 on win2k. production machine is postgresql on linux (haven't had a chance to test it out on postgresql yet though).


Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 04, 2003 11:24 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
Code:
<property name="content" type="string">
  <column name="content" sql-type="text"/>
</property>

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 04, 2003 11:29 am 
Newbie

Joined: Tue Nov 04, 2003 10:08 am
Posts: 3
excellent. thanks!


Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 04, 2003 4:10 pm 
Beginner
Beginner

Joined: Tue Sep 23, 2003 5:00 pm
Posts: 40
Hi,

epbernard wrote:
Code:
<property name="content" type="string">
  <column name="content" sql-type="text"/>
</property>


That's interesting and that works with MySQL. I didn't know this SQL type.

Is it in SQL2 standard ?

Is it supported by most RDBMS ?

sylvain_2020


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