-->
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.  [ 1 post ] 
Author Message
 Post subject: Howto write mapping file to get SqlTypes content?
PostPosted: Tue Apr 01, 2008 8:19 am 
Newbie

Joined: Thu Nov 15, 2007 7:31 am
Posts: 4
Location: Denmark, CET
Problem
I would like to be able to fetch the length of a property from the hibernate mapping information. I have found other entries in this forum stating that I shall use SqlTypes() method from iType. But the problem is that when I do that I always get a SqlType defintion with length set to 0. I have tried varius ways of setting the length attribute - both in the property tag and also as shown below in the column part of a mapping. In all cases I get a SqlType object with Length = 0 and LengthDefined = false.

Can anybody guide in the right direction for retrieving this form for metadata or simply indicate what I am doing wrong.

Thanks in advance.

Hibernate version: NHibernate 1.2.1

Mapping documents:
Code:
  <class name="TypeCatalog, Mimer.Data" table="CAT_TYPE_TB" lazy="false" >
    <id name="OID" column="OID" type="string">
      <generator class="assigned" />
    </id>
    <version name="Version" column="VERSION" unsaved-value="-1"/>
    <property name="Type" type="string" >
      <column name="TYPE_VALUE" not-null="true" sql-type="VARCHAR2(100)" length="100" />
    </property>

  </class>


Code used to fetch length information:
Code:
        public int GetPropertyLength(PropertyInfo info) {
            int length = 20;
            IClassMetadata metaData = DataAccessHttpModule.CurrentFactory.GetClassMetadata(info.ReflectedType);
            IType type = metaData.GetPropertyType(info.Name);
            if (type != null) {
                SqlType[] sqlTypes = type.SqlTypes((IMapping)DataAccessHttpModule.CurrentFactory);
                if( sqlTypes[0].LengthDefined ) {
                    length = sqlTypes[0].Length;
                } else {
                // TODO log an error
                }
            } else {
                // TODO log an error
            }
            return length;
        }


Name and version of the database you are using: Oracle 9


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

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:
cron
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.