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>
|