-->
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: Column missing length attribute for varchar in reverse eng
PostPosted: Tue Sep 09, 2008 7:32 pm 
Newbie

Joined: Thu Aug 21, 2008 7:54 pm
Posts: 12
Hibernate version:
Hibernate Tools 3.2.2.GA / Eclipse 3.4

Mapping documents:
Example:
Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<!-- Generated Sep 9, 2008 3:03:57 PM by Hibernate Tools 3.2.2.GA -->
<hibernate-mapping>
    <class name="com.mycompany.domain.generated.Action" table="action">
        <id name="actionId" type="java.lang.Integer">
            <column name="actionID" />
            <generator class="identity" />
        </id>
        <property name="name" type="string">
            <column name="name" not-null="true" unique="true" />
        </property>
        <property name="idType1" type="string">
            <column name="idType1" length="50" />
        </property>
    </class>
</hibernate-mapping>


Table Syntax
CREATE TABLE `action` (
`actionID` int(10) unsigned NOT NULL AUTO_INCREMENT,
`name` varchar(255) NOT NULL DEFAULT '',
`idType` varchar(50) DEFAULT NULL,
PRIMARY KEY (`actionID`),
) ENGINE=InnoDB DEFAULT CHARSET=utf8

Name and version of the database you are using:
MySQL 5.1.26-rc


I'm using Hibernate Tools in Eclipse to reverse engineer a fairly large existing database. For some reason the hbm files that are generated only contain the length attribute for columns when the length of the database field is less than 255. I have other tables in which both field are nullable and issue still exists, it seems to be directly related to the length of 255.

Does this ring a bell for anyone? Thanks


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 10, 2008 1:50 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
yes, 255 is the default length so we don't generate it (we like tidy configuraiton files ;)

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 10, 2008 1:19 pm 
Newbie

Joined: Thu Aug 21, 2008 7:54 pm
Posts: 12
Thanks, that explains it. Is there an easy way to turn that on? So that 255 would be specified for the sake of clarity. I realize this is a very slippery slope and we don't want to explicitly show ALL defaults ;)


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 11, 2008 2:25 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
you can adjust the templates for your liking...

_________________
Max
Don't forget to rate


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.