-->
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.  [ 9 posts ] 
Author Message
 Post subject: varchar with fix length
PostPosted: Thu Apr 26, 2007 4:52 am 
Newbie

Joined: Wed Apr 25, 2007 6:03 am
Posts: 6
hi,
how can i specify a String that has to have the exact length of "2" in the mapping file? As far as I understood the length="2" command indicates a maximum length of "2". Can anyone help me?

regards

mono


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 26, 2007 5:07 am 
Senior
Senior

Joined: Sat Apr 21, 2007 11:01 pm
Posts: 144
In Java you cant create a String with a specifc length, but you might be able to use a good old char[].


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 26, 2007 5:27 am 
Newbie

Joined: Wed Apr 25, 2007 6:03 am
Posts: 6
hi,
first of all thank u but i have to specify the type in the hibernate mapping in order to get this fix length as the java files are completly generated :(

is there something in the type=" " or sql-type=" " command that could do the same?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 26, 2007 5:31 am 
Senior
Senior

Joined: Sat Apr 21, 2007 11:01 pm
Posts: 144
I think you can do that in the revenge file, for example:
Code:
   <table catalog="cat" schema="dbo" name="Table">
      <primary-key>
         <generator class="native" />
      </primary-key>
      <column name="id" />
      <column name="initials" property="char[]" type="integer" />   
   </table>

I've only been playing with hibernate setup for like 3 days though, lol.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 26, 2007 5:39 am 
Newbie

Joined: Wed Apr 25, 2007 6:03 am
Posts: 6
Code:
org.hibernate.MappingException: invalid mapping
[hibernatetool] org.xml.sax.SAXParseException: Attribute "property" must be declared for element type "column".


Thats what i tried, too :) i think it has to exist a command like minLength and maxLength but they give the same Exception...


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 26, 2007 5:47 am 
Senior
Senior

Joined: Sat Apr 21, 2007 11:01 pm
Posts: 144
Can you past your revenge file.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 26, 2007 5:58 am 
Newbie

Joined: Wed Apr 25, 2007 6:03 am
Posts: 6
Code:
<class name="Country" table="country">
        <id name="countryCode" column="country_code" type="java.lang.String">
</id>
<property name="languageId"  >
           <column name="language_id" sql-type="varchar(2)" not-null="true" />
        </property>


thats how it looks like , but with varchar(2) its also possible to insert 'a' e.g.
and thats what i want to avoid, as the language id has to have 2 chars....


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 26, 2007 6:26 am 
Senior
Senior

Joined: Sat Apr 21, 2007 11:01 pm
Posts: 144
That's from a hbm.xml not a reveng file. T_T


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 26, 2007 6:33 am 
Newbie

Joined: Wed Apr 25, 2007 6:03 am
Posts: 6
thats waht i said a hibernate mapping (hbm) ... but i didn't read ur post properly sry x.x"


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