-->
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.  [ 2 posts ] 
Author Message
 Post subject: globally changing type mappings for Oracle 9i database?
PostPosted: Fri Aug 06, 2004 5:52 pm 
Newbie

Joined: Tue Jul 20, 2004 1:25 pm
Posts: 12
I am trying to execute a query and map it to the TeamUser class (mapping below). However, when I execute the query it defaults to BigDecimal for all the NUMBER(38) columns in the query. I would like to have the query return long datatype for these columns.

Is there a way to globally change the default mapping so that long datatypes are returned instead of BigDecimal? If I use a UserType I have to specify the UserType in every mapping file that needs this behavior, correct? Is it acceptable to extend the Oracle dialect to return the desired datatype?

thanks,
Brett Bandy



Hibernate version:2.1.2

Code between sessionFactory.openSession() and session.close():

// start a session and transaction
// create a new session to the database and start a transaction
Session session = sessionFactory.openSession();
Transaction trans = session.beginTransaction();

retval = session.createSQLQuery(sql, alias, mappingClass).list();


// commit the transaction and close the session
trans.commit();
session.close();


Mapping file:

<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 2.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd" >

<hibernate-mapping>

<class
name="com.complete.package.name.TeamUser"
mutable="false"
>

<meta attribute="implement-equals">true</meta>

<composite-id>
<key-property name="teamName" type="java.lang.String" column="TEAMNAME"/>
<key-property name="featureSetId" type="long" column="FEATURESET"/>
<key-property name="userId" type="long" column="USERID"/>
</composite-id>

<property
name="lastName"
type="java.lang.String"
column="LASTNAME"
not-null="true">
<meta attribute="use-in-tostring">true</meta>
</property>

<property
name="firstName"
type="java.lang.String"
column="FIRSTNAME"
not-null="true">
<meta attribute="use-in-tostring">true</meta>
</property>

<property
name="loginName"
type="java.lang.String"
column="LOGINNAME"
not-null="true">
<meta attribute="use-in-tostring">true</meta>
</property>

<property
name="media"
type="java.lang.String"
column="MEDIA"
not-null="true">
<meta attribute="use-in-tostring">true</meta>
</property>

<property
name="mediaTypeId"
type="long"
column="MEDIATYPE_ID"
not-null="true">
<meta attribute="use-in-tostring">true</meta>
</property>

<property
name="idleReason"
type="java.lang.String"
column="IDLEREASON"
not-null="true">
<meta attribute="use-in-tostring">true</meta>
</property>

<property
name="status"
type="java.lang.String"
column="STATUS"
not-null="true">
<meta attribute="use-in-tostring">true</meta>
</property>

<property
name="statusId"
type="long"
column="STATUSID"
not-null="true">
<meta attribute="use-in-tostring">true</meta>
</property>

<property
name="nodeName"
type="java.lang.String"
column="NODENAME"
not-null="true">
<meta attribute="use-in-tostring">true</meta>
</property>

<property
name="statusDuration"
type="long"
column="STATUSDURATION"
not-null="true">
<meta attribute="use-in-tostring">true</meta>
</property>

<!-- associations -->

</class>
</hibernate-mapping>


Top
 Profile  
 
 Post subject:
PostPosted: Sat Aug 07, 2004 8:42 am 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
You can make your own custom Dialect for that, should be easy.


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