-->
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: Cant insert object, save dont persist item
PostPosted: Wed Feb 09, 2005 2:54 pm 
Beginner
Beginner

Joined: Fri Apr 16, 2004 10:25 am
Posts: 44
Location: Brazil
Read the rules before posting!
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version: 2.1.8

Mapping documents:


Code between sessionFactory.openSession() and session.close():
[code]
Transaction tx = HibernateUtil.getSession().beginTransaction();

DynaActionForm dynaForm = (DynaActionForm) form;

empresaVO empresa = new empresaVO();
empresa.setIdEmpresa((Long)dynaForm.get("ID_EMPRESA"));
empresa.setVchnome((String)dynaForm.get("VCHNOME"));

String data = (String)dynaForm.get("DTECADASTRO");
SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy");
empresa.setDtecadastro(sdf.parse(data));

empresa.setVchnomecontato((String)dynaForm.get("VCHNOMECONTATO"));
empresa.setVchfonecontato((String)dynaForm.get("VCHFONECONTATO"));
empresa.setVchfone((String)dynaForm.get("VCHFONE"));
empresa.setVchstatus((String)dynaForm.get("VCHSTATUS"));

EmpresasDAO empresasDAO = new EmpresasDAO();
empresasDAO.insert(empresa);

tx.commit();
HibernateUtil.closeSession();
[code]
[code]
public static Session getSession()
throws DAOException {
Session s = (Session) threadSession.get();
try {
if (s == null) {
log.debug("Opening new Session for this thread.");
s = getSessionFactory().openSession();
log.debug("autocommit = "+s.connection().getAutoCommit());
threadSession.set(s);
}
} catch (HibernateException ex) {
throw new DAOException(ex);
} catch (SQLException ex) {
log.debug("Couldn't set autocommit to false");
throw new DAOException(ex);
}
return s;
}

/**
* Closes the Session local to the thread.
*/
public static void closeSession()
throws DAOException {
try {
Session s = (Session) threadSession.get();
if (s != null && s.isOpen()) {
log.debug("Closing Session of this thread.");
s.close();
threadSession.set(null);
}
} catch (HibernateException ex) {
throw new DAOException(ex);
}
}
[/code]
Name and version of the database you are using: Oracle 8i

The generated SQL (show_sql=true):
WARN [http-8080-Processor23] (ValidSessionFilter.java:45) - ValidSessionFilter Usuario Valido
DEBUG [http-8080-Processor23] (HibernateUtil.java:124) - Opening new Session for this thread.
DEBUG [http-8080-Processor23] (HibernateUtil.java:126) - autocommit = true
INFO [http-8080-Processor23] (EmpresasAction.java:115) - Alterando empresa
DEBUG [http-8080-Processor23] (Dao.java:43) - makePersistent com.bzo2.lupo.vo.empresaVO
DEBUG [http-8080-Processor23] (HibernateUtil.java:146) - Closing Session of this thread.


Top
 Profile  
 
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.