-->
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: wrong column length if using character type
PostPosted: Mon Nov 08, 2004 12:08 pm 
Beginner
Beginner

Joined: Mon Nov 08, 2004 11:58 am
Posts: 20
Hi,

I am using XDoclet and hbm2ddl. In my classes, I have something like

/**
* @return Returns the strFirstName.
*
* @hibernate.property
* type="character"
* column="FIRSTNAME"
* length="32"
* not-null="true"
*/
public String getStrFirstName() {
return strFirstName;
}
...

The generated mapping looks fine:

<property
name="strFirstName"
type="character"
update="true"
insert="true"
access="property"
column="FIRSTNAME"
length="32"
not-null="true"
/>
...

However, if I generate the ddl using SchemaExport, the sql output is

create table PERSON (
...
FIRSTNAME char(1) not null,
...
);

Obviously the column length has been changed to 1. If I am using "string" as type, then the generated length is 32. Any idea?

thx.
sven


Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 08, 2004 12:35 pm 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
use type="string" sql-type="whatever"


Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 08, 2004 2:16 pm 
Beginner
Beginner

Joined: Mon Nov 08, 2004 11:58 am
Posts: 20
michael wrote:
use type="string" sql-type="whatever"


does not work either. I have the following changes:

/**
* @return Returns the strLastName.
*
* @hibernate.property
* type="string"
*
* @hibernate.column
* name="LASTNAME"
* sql-type="char"
* length="32"
* not-null="true"
*/
public String getStrLastName() {
return strLastName;
}


generated mapping:

<property
name="strLastName"
type="string"
update="true"
insert="true"
access="property"
>
<column
name="LASTNAME"
length="32"
not-null="true"
sql-type="char"
/>
</property>


generated sql:

create table PERSON (
PERSON_ID bigint generated by default as identity (start with 1),
...
LASTNAME char not null
...
);


now there is no specified column length at all. any help appreciated.

sven


Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 08, 2004 3:01 pm 
Beginner
Beginner

Joined: Mon Nov 08, 2004 11:58 am
Posts: 20
I did some research and found on

http://cephas.net/blog/2004/06/29/hiber ... ength.html

some interesting stuff related to this topic. Although the author there was not sure whether this is a bug or a feature, I am pretty sure now this is a bug.

Other considerations?


Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 08, 2004 6:21 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 7:19 pm
Posts: 2364
Location: Brisbane, Australia
Its correct. If you are defining an SQL type then this over rides the other properties that are DDL type related. So you should include the length if is approrpriate for the type being defined.


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.