-->
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: problem while saving object.
PostPosted: Mon Apr 16, 2007 2:40 am 
Newbie

Joined: Mon Apr 16, 2007 2:30 am
Posts: 8
Location: Lahore
hi, i got a problem while saving object, but the selection queries running fine. There is no exception throws but object is not persisted even console prints the next value for ID filed like

"11:15:21,656 INFO [Server] JBoss (MX MicroKernel) [4.0.5.GA (build: CVSTag=Bran
ch_4_0 date=200610162339)] Started in 29s:391ms
11:15:41,812 INFO [STDOUT] Hibernate: select max(cid) from companies
11:15:42,265 INFO [STDOUT] Hibernate: select companyimp0_.cid as cid0_, company
imp0_.company_name as company2_0_ from companies companyimp0_"

My code is


public class CompanyDAOImpl implements CompanyDAO {

SessionFactory sessionFactory;
Session session;
Transaction trans;
java.io.Serializable ser;

public CompanyDAOImpl() {
}

public void insert(CompanyImpl company){
try{
session = this.getCurrentSession();

trans = session.getTransaction();
trans.begin();
session.saveOrUpdate(company);

trans.commit();

java.util.List l= (java.util.List)session.createQuery("from com.springer.impl.CompanyImpl").list();
for(int i=0; i<l.size(); i++){
System.out.println(((CompanyImpl)l.get(i)).companyName);
}

} catch (Exception ex){
ex.printStackTrace();
trans.rollback();
} finally {
session.close();
}
}


Kindly send me comment about to resolve that problem.

thanks

_________________
Kashif Bashir

Mobex Limited
kashefbasher@gmail.com


Top
 Profile  
 
 Post subject: problem while saving object.
PostPosted: Mon Apr 16, 2007 5:49 am 
Newbie

Joined: Mon Apr 16, 2007 2:30 am
Posts: 8
Location: Lahore
hi, i got a problem while saving object, but the selection queries running fine. There is no exception throws but object is not persisted even console prints the next value for ID filed like

"11:15:21,656 INFO [Server] JBoss (MX MicroKernel) [4.0.5.GA (build: CVSTag=Bran
ch_4_0 date=200610162339)] Started in 29s:391ms
11:15:41,812 INFO [STDOUT] Hibernate: select max(cid) from companies
11:15:42,265 INFO [STDOUT] Hibernate: select companyimp0_.cid as cid0_, company
imp0_.company_name as company2_0_ from companies companyimp0_"

My code is


public class CompanyDAOImpl implements CompanyDAO {

SessionFactory sessionFactory;
Session session;
Transaction trans;
java.io.Serializable ser;

public CompanyDAOImpl() {
}

public void insert(CompanyImpl company){
try{
session = this.getCurrentSession();

trans = session.getTransaction();
trans.begin();
session.saveOrUpdate(company);

trans.commit();

java.util.List l= (java.util.List)session.createQuery("from com.springer.impl.CompanyImpl").list();
for(int i=0; i<l.size(); i++){
System.out.println(((CompanyImpl)l.get(i)).companyName);
}

} catch (Exception ex){
ex.printStackTrace();
trans.rollback();
} finally {
session.close();
}
}


Kindly send me comment about to resolve that problem.

thanks

_________________
Kashif Bashir

Mobex Limited
kashefbasher@gmail.com


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.