Win a copy of Rust Web Development this week in the Other Languages forum!

Mridul Paliwal

Greenhorn
+ Follow
since Jun 08, 2004
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Mridul Paliwal

Wrapping it in a transaction did it for me.
But it was working without it earlier.
I guess i'll have to dig deeper into Hibernate.

Also, Although i invoke flush here, it worked even without it.

Account a = new Account();
a.setAccountName("Direct Create");
a.setAccountType("standard");
try{
Session s = HibernateSession.currentSession(null);
Transaction t = s.beginTransaction();
HibernateSession.currentSession(null).save(a);
HibernateSession.currentSession(null).flush();
t.commit();
}catch(Exception e){
e.printStackTrace();
}
hi,

I am seeing the same behavior.
Did u figure out what was wrong?

like mentioned in the post, the insert statements do show in the debug.
I am guessing
- Transaction Manager (using default)
- Caching (using default)
- hashcode and equals implementations


I also do get the object back, but it's just not persisted to the database.
basically this test succeeds

public void testInsert() throws DataAccessException{
String strName = "From Test ";
Account a = new Account();
a.setAccountName(strName);
Account ret = (Account) new AccountDAO().insert(a);
assertNotNull(ret.getObjectId());

Account ar = new AccountDAO().getByName(strName);
assertEquals(strName,ar.getAccountName());
}