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: HibernateQuery return null value even data is present
PostPosted: Sun Oct 24, 2010 2:19 pm 

Joined: Sun Oct 24, 2010 1:13 pm
Posts: 1
Hi All,

We recently upgraded from 8.1 to 10.3 and we are using Sybase 12.5 as our database. We use hibernate 2.1.6 jar and jonn3 as our driver.
The issue is about reteiving data for acolumn from database. We inserted new data and read data in the same session. Then we closed our application and rebounced our servers and we get null for the same data for that column. We dont have any secondary cache. The column is of type char(2) and not null in database. The column is defined as a type of org.apache.commons.lang.enums.Enum in java. Hibernate mapping for that columns is defined as below

The query we used is
"select new com.xxx.domain.OutboundInventoryAttributes("
+ "PI.cusip, min(PI.wireDt), max(PI.wireDt), SNAP.reSecId, PIP.invntyCd) from " +
"PortInventoryPiece as PIP, " +
"PortInventory as PI, " +
"OutboundInventoryPiece as SNAP " +
"where " +
"SNAP.reSecId = :reSecId and " +
"PIP.id.expcttnRefNo = SNAP.expcttnRefNo and " +
"PIP.id.expcttnSrcCd = SNAP.expcttnSrcCd and " +
"PIP.id.pieceSeqNo = SNAP.sequenceNumber and " +
"PIP.id.expcttnRefNo = PI.id.expcttnRefNo and " +
"PIP.id.expcttnSrcCd = PI.id.expcttnSrcCd and " +
"PIP.bookStatCd = :bookStatus " +
"group by PI.cusip, PIP.invntyCd, SNAP.reSecId";

The constructor for OutboundInventoryAttributes is as below

public OutboundInventoryAttributes(
String cusip,
Date minWireDt,
Date maxWireDt,
Integer reSecId,
String invntyCd) {

System.out.println("Inventory code from Hibernate" + invntyCd);

this.cusip = cusip;
this.minWireDt = new Timestamp(minWireDt.getTime());
this.maxWireDt = new Timestamp(maxWireDt.getTime());
this.invntyCd = invntyCd;
this.reSecId = reSecId;

The nullSafeGet is defined as below

ublic Object nullSafeGet(ResultSet rs, String[] names, Object owner) throws HibernateException, SQLException {
String enumCode = null;

// get the value into the resultset based on the column type
switch(getColumnType()) {
case INT_TYPE:
enumCode = ((Integer)Hibernate.INTEGER.nullSafeGet(rs, names[0])).toString();
enumCode = ((Long)Hibernate.LONG.nullSafeGet(rs, names[0])).toString();
enumCode = (String) Hibernate.STRING.nullSafeGet(rs, names[0]);

return EnumUtils.getEnum(this.enumClass, enumCode);

Please let me know if anyone have some suggestions for this problem.

Thanks in Advance

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