-->
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.  [ 5 posts ] 
Author Message
 Post subject: update problems with Hibernate 2.0.3
PostPosted: Mon Sep 15, 2003 8:19 pm 
Beginner
Beginner

Joined: Thu Sep 04, 2003 1:46 pm
Posts: 20
Hi,

Has anyone run across a problem with Hibernate? We're trying to update a persistent object and the first mapped column's data (a string) always get corrupted.

The insert statement works fine, but updates aren't working.

The Hibernate SQL statement looks fine and printouts of the Data in my application looks fine before and after the call to Hibernate's update statement.

Any help would be appreciated.

Thanks,
-bnl


Top
 Profile  
 
 Post subject:
PostPosted: Mon Sep 15, 2003 9:08 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 3:00 pm
Posts: 1816
Location: Austin, TX
No problems here.

How about posting the relevant mappings and mapped class, as well as a simple snippet showing what you are attempting.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Sep 15, 2003 10:01 pm 
Beginner
Beginner

Joined: Thu Sep 04, 2003 1:46 pm
Posts: 20
Here is my mapping file:

<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">
<hibernate-mapping>
<class name="com.ditech.signingappt.db.WebAppUserDbBean" table="web_app_users">
<id name="username" type="string" column="username" >
<generator class="assigned" />
</id>

<property name="fname" column="fname" type="string" />
<property name="lname" column="lname" type="string" />
<property name="role_cd" column="role_cd" type="string" />
<property name="status" column="status" type="string" />
<property name="notes" column="notes" type="string" />
<property name="insert_date" column="insert_date" type="timestamp" />
<property name="password" column="usr_pswd" type="string" />

<set name="vendors" table="WEB_APP_USER_VENDOR_MAP" >
<key column="username" />
<many-to-many class="com.ditech.signingappt.db.VendorDbBean" column="comp_cd" />
</set>
</class>
</hibernate-mapping>


My persistent class:

public class WebAppUserDbBean implements Serializable {

private String username;
private String fname;
private String lname;
private String role_cd;
private String status;
private String notes;
private Timestamp insert_date;
private String password;
private Set vendors;

public WebAppUserDbBean() {
}

public WebAppUserDbBean(String username, String fname, String lname,
String role_cd, String status, String notes,
Timestamp insert_date, String password,
Set vendors) {
this.username = (username != null) ? username.trim().toUpperCase() : username;
this.fname = fname;
this.lname = lname;
this.role_cd = role_cd;
this.status = (status != null) ? status.trim().toUpperCase() : status;
this.notes = notes;
this.insert_date = insert_date;
this.password = password;
this.vendors = vendors;
}

public String getUsername() {
return username;
}

public void setUsername(String username) {
this.username = (username != null) ? username.trim().toUpperCase() : username;
}

public String getFname() {
return fname;
}

public void setFname(String fname) {
this.fname = fname;
}

public String getLname() {
return lname;
}

public void setLname(String lname) {
this.lname = lname;
}

public String getRole_cd() {
return role_cd;
}

public void setRole_cd(String role_cd) {
this.role_cd = role_cd;
}

public String getStatus() {
return status;
}

public void setStatus(String status) {
this.status = (status != null) ? status.trim().toUpperCase() : status;
}

public String getNotes() {
return notes;
}

public void setNotes(String notes) {
this.notes = notes;
}

public Timestamp getInsert_date() {
return insert_date;
}

public void setInsert_date(Timestamp insert_date) {
this.insert_date = insert_date;
}

public String getPassword() {
return password;
}

public void setPassword(String password) {
this.password = password;
}

public Set getVendors() {
return vendors;
}

public void setVendors(Set vendors) {
this.vendors = vendors;
}

/**
* debug method.
* @return
*/
public String toString() {

String str = "\nWebAppUser - \n"
+ "\tUsername: " + this.username
+ "\n\tFname: " + this.fname
+ "\n\tLname: " + this.lname
+ "\n\tRole_cd: " + this.role_cd
+ "\n\tStatus: " + this.status
+ "\n\tInsert_date: " + this.insert_date
+ "\n\tVendors: " + this.vendors
+ "\n\tNotes: " + this.notes
;

if (vendors != null) {
str += "\n\tNum vendors: " + vendors.size();
}

return str;
}
}


My call to Hibernate:

public static void update(Object instance) throws DataAccessObjectException {
Session session;

if (log.isTraceEnabled()) {
log.trace("update: begin");
}

session = openSession();

try {
session.update(instance);
if (log.isDebugEnabled()) {
log.debug("update: called session.update()");
}
} catch (Exception e) {
log.error("update: update() failed", e);
throw new DataAccessObjectException("update() failed", e);
} finally {
try {
closeWithCommit(session);
} finally {
if (log.isTraceEnabled()) {
log.trace("update: end");
}
}
}
}

There's some wrapper classes and all, but they are basically pass throughs to Hibernate methods.

We're also using the Transport Object pattern, but those are just serializable JavaBeans.

No matter what I try, the first string column that is updated by Hibernate gets corrupted.

Is it possible that this is a character set mismatch between my Weblogic server and the Oracle Database?

Everything works fine through a JUnit test class running with net.sf.hibernate.transaction.JDBCTransactionFactory

Weblogic is using net.sf.hibernate.transaction.JTATransactionFactory

Both are using net.sf.hibernate.dialect.OracleDialect

-bnl


Top
 Profile  
 
 Post subject:
PostPosted: Mon Sep 15, 2003 10:21 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 3:00 pm
Posts: 1816
Location: Austin, TX
If it were a mismatch between character sets on the oracle client and server, it would not just be the first string column; it would be all of them.

Everything else looks OK (although I'd be very careful resetting values in property setters).

How is the column defined in the Oracle table? Are you using a hibernate interceptor at either the session or session factory level? What functionality are they performing?

How about enabling Hibernate's logging to debug and posting the output.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Sep 16, 2003 1:14 pm 
Beginner
Beginner

Joined: Thu Sep 04, 2003 1:46 pm
Posts: 20
Hi,

I'm not using an interceptor.

Here's the Hibernate logging statements. It appears to bind the correct value to the prepared statement.

The column is a VARCHAR2(15).

Something interesting is that I added a dummy junk column of the same type.

I think map the same property to both the junk column and the actual column.

<property name="fname" column="junk" type="string" />
<property name="fname" column="fname" type="string" />

Both of these columns now update correctly. I thought that the first column, the junk column, would be corrupted and the fname column would be fine. I find it odd that both columns are ok.

Any suggestions?

I thought about implementing the Lifecycle interface or to add an Interceptor to see what was going on, but since Hibernate's debugging statements show that the correct value is being bound to the prepared statement, should I even pursue this?

Here are the debug statements:

2003-09-16 09:59:34,195 [ExecuteThread: '11' for queue: 'default'](EntityPersist
er.java:617) DEBUG - Updating entity: com.ditech.signingappt.db.WebAppUserDbBea
n#BNL
2003-09-16 09:59:34,195 [ExecuteThread: '11' for queue: 'default'](BatcherImpl.j
ava:166) DEBUG - about to open: 0 open PreparedStatements, 0 open ResultSets
2003-09-16 09:59:34,195 [ExecuteThread: '11' for queue: 'default'](DriverManager
ConnectionProvider.java:77) DEBUG - total checked-out connections: 0
2003-09-16 09:59:34,195 [ExecuteThread: '11' for queue: 'default'](DriverManager
ConnectionProvider.java:83) DEBUG - using pooled JDBC connection, pool size: 0
2003-09-16 09:59:34,195 [ExecuteThread: '11' for queue: 'default'](SessionFactor
yImpl.java:526) DEBUG - prepared statement get: update web_app_users set fname=
?, lname=?, role_cd=?, status=?, notes=?, insert_date=?, usr_pswd=? where userna
me=?
Hibernate: update web_app_users set fname=?, lname=?, role_cd=?, status=?, notes
=?, insert_date=?, usr_pswd=? where username=?
2003-09-16 09:59:34,210 [ExecuteThread: '11' for queue: 'default'](SessionFactor
yImpl.java:536) DEBUG - preparing statement
2003-09-16 09:59:34,210 [ExecuteThread: '11' for queue: 'default'](EntityPersist
er.java:366) DEBUG - Dehydrating entity: com.ditech.signingappt.db.WebAppUserDb
Bean#BNL
2003-09-16 09:59:34,210 [ExecuteThread: '11' for queue: 'default'](NullableType.
java:44) DEBUG - binding 'Benson' to parameter: 1
2003-09-16 09:59:34,210 [ExecuteThread: '11' for queue: 'default'](NullableType.
java:44) DEBUG - binding 'Liu' to parameter: 2
2003-09-16 09:59:34,210 [ExecuteThread: '11' for queue: 'default'](NullableType.
java:44) DEBUG - binding 'vend' to parameter: 3
2003-09-16 09:59:34,210 [ExecuteThread: '11' for queue: 'default'](NullableType.
java:44) DEBUG - binding 'A' to parameter: 4
2003-09-16 09:59:34,210 [ExecuteThread: '11' for queue: 'default'](NullableType.
java:44) DEBUG - binding '' to parameter: 5
2003-09-16 09:59:34,210 [ExecuteThread: '11' for queue: 'default'](NullableType.
java:44) DEBUG - binding '16 September 2003 09:59:34' to parameter: 6
2003-09-16 09:59:34,210 [ExecuteThread: '11' for queue: 'default'](NullableType.
java:44) DEBUG - binding 'E+zHj0BN0lihefdGmRMLUollTy8n9NGB8wyj4uD9ti0=' to para
meter: 7
2003-09-16 09:59:34,210 [ExecuteThread: '11' for queue: 'default'](NullableType.
java:44) DEBUG - binding 'BNL' to parameter: 8
2003-09-16 09:59:34,210 [ExecuteThread: '11' for queue: 'default'](BatchingBatch
er.java:24) DEBUG - Adding to batch
2003-09-16 09:59:34,210 [ExecuteThread: '11' for queue: 'default'](BatchingBatch
er.java:46) DEBUG - Executing batch size: 1
2003-09-16 09:59:34,210 [ExecuteThread: '11' for queue: 'default'](BatcherImpl.j
ava:173) DEBUG - done closing: 0 open PreparedStatements, 0 open ResultSets


-bnl


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