-->
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.  [ 4 posts ] 
Author Message
 Post subject: Configuration problem?
PostPosted: Mon Nov 10, 2003 11:42 am 
Newbie

Joined: Mon Nov 10, 2003 10:37 am
Posts: 3
Location: Hungary
Hello, I need yor help:
I want to use Hibernate with Jboss-3.2.2. I have already the databasetables & I want to save an object, but the session.save has no effect. I think somehow the hibernate doesn't have access to my tables. And I have no error message.

Code:
16:21:51,921 INFO  [STDOUT] 16:21:51,921 INFO  [Configuration] Configuration res
ource: /hibernate.cfg.xml
16:21:51,937 INFO  [STDOUT] 16:21:51,937 INFO  [Configuration] Mapping resource:
air/tm/model/Domain.hbm.xml
16:21:52,046 INFO  [STDOUT] 16:21:52,046 INFO  [Binder] Mapping class: air.tm.mo
del.Domain -> domainTM
16:21:52,046 INFO  [STDOUT] 16:21:52,046 INFO  [Configuration] Mapping resource:
air/tm/model/Group.hbm.xml
16:21:52,109 INFO  [STDOUT] 16:21:52,109 INFO  [Binder] Mapping class: air.tm.mo
del.Group -> groupTM
16:21:52,125 INFO  [STDOUT] 16:21:52,109 INFO  [Binder] Mapping collection: air.
tm.model.Group.users -> roleTM
16:21:52,125 INFO  [STDOUT] 16:21:52,125 INFO  [Configuration] Mapping resource:
air/tm/model/Info.hbm.xml
16:21:52,203 INFO  [STDOUT] 16:21:52,203 INFO  [Binder] Mapping class: air.tm.mo
del.Info -> infoTM
16:21:52,203 INFO  [STDOUT] 16:21:52,203 INFO  [Configuration] Mapping resource:
air/tm/model/Mod.hbm.xml
16:21:52,281 INFO  [STDOUT] 16:21:52,281 INFO  [Binder] Mapping class: air.tm.mo
del.Mod -> modTM
16:21:52,281 INFO  [STDOUT] 16:21:52,281 INFO  [Configuration] Mapping resource:
air/tm/model/User.hbm.xml
16:21:52,343 INFO  [STDOUT] 16:21:52,343 INFO  [Binder] Mapping class: air.tm.mo
del.User -> userTM
16:21:52,343 INFO  [STDOUT] 16:21:52,343 INFO  [Binder] Mapping collection: air.
tm.model.User.groups -> roleTM
16:21:52,343 INFO  [STDOUT] 16:21:52,343 INFO  [Configuration] Configured Sessio
nFactory: java:comp/env/hibernate/SessionFactory
16:21:52,343 INFO  [STDOUT] 16:21:52,343 INFO  [Configuration] processing one-to
-many association mappings
16:21:52,343 INFO  [STDOUT] 16:21:52,343 INFO  [Binder] Mapping collection: air.
tm.model.Domain.groupList -> groupTM
16:21:52,343 INFO  [STDOUT] 16:21:52,343 INFO  [Binder] Mapping collection: air.
tm.model.Domain.info -> infoTM
16:21:52,359 INFO  [STDOUT] 16:21:52,359 INFO  [Binder] Mapping collection: air.
tm.model.Info.mod -> modTM
16:21:52,359 INFO  [STDOUT] 16:21:52,359 INFO  [Configuration] processing foreig
n key constraints
16:21:52,359 INFO  [STDOUT] 16:21:52,359 INFO  [SessionFactoryImpl] building ses
sion factory
16:21:52,359 INFO  [STDOUT] 16:21:52,359 INFO  [Dialect] Using dialect: net.sf.h
ibernate.dialect.MySQLDialect
16:21:52,359 INFO  [STDOUT] 16:21:52,359 INFO  [NamingHelper] JNDI InitialContex
t properties:{}
16:21:52,359 INFO  [STDOUT] 16:21:52,359 INFO  [DatasourceConnectionProvider] Us
ing datasource: java:comp/env/jdbc/MysqlDS
16:21:52,359 INFO  [STDOUT] 16:21:52,359 INFO  [SessionFactoryImpl] Use outer jo
in fetching: true
16:21:52,359 INFO  [STDOUT] 16:21:52,359 INFO  [SessionFactoryImpl] Use scrollab
le result sets: true
16:21:52,359 INFO  [STDOUT] 16:21:52,359 INFO  [SessionFactoryImpl] Transaction
strategy: net.sf.hibernate.transaction.JTATransactionFactory
16:21:52,359 INFO  [STDOUT] 16:21:52,359 INFO  [NamingHelper] JNDI InitialContex
t properties:{}
16:21:52,359 INFO  [STDOUT] 16:21:52,359 INFO  [JTATransactionFactory] No Transa
ctionManagerLookup configured (use of JCS read-write cache is not recommended)
16:21:52,359 INFO  [STDOUT] 16:21:52,359 INFO  [SessionFactoryImpl] echoing all
SQL to stdout
16:21:52,375 INFO  [STDOUT] 16:21:52,375 INFO  [SessionFactoryObjectFactory] Fac
tory name: java:comp/env/hibernate/SessionFactory
16:21:52,375 INFO  [STDOUT] 16:21:52,375 INFO  [NamingHelper] JNDI InitialContex
t properties:{}
16:21:52,375 INFO  [STDOUT] 16:21:52,375 INFO  [SessionFactoryObjectFactory] Bou
nd factory to JNDI name: java:comp/env/hibernate/SessionFactory
16:21:52,375 INFO  [STDOUT] 16:21:52,375 WARN  [SessionFactoryObjectFactory] Ini
tialContext did not implement EventContext
16:21:52,375 INFO  [STDOUT] 16:21:52,375 INFO  [SessionFactoryImpl] Query langua
ge substitutions: {}


---*---

My hibernate.cfg.xml looks like this:

Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD//EN" "http://hibernate.sourceforge.net/hibernate-configuration-2.0.dtd">

<hibernate-configuration>
<!-- a SessionFactory instance listed as /jndi/name -->
<session-factory name="java:comp/env/hibernate/SessionFactory">

<!-- properties -->
<property name="connection.datasource">java:comp/env/jdbc/MysqlDS</property>


<property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="hibernate.connection.url">jdbc:mysql://213.163.10.98:3306/jboss</property>
<property name="hibernate.connection.username">jboss</property>
<property name="hibernate.connection.password">jboss</property>
<property name="show_sql">true</property>
<property name="dialect">net.sf.hibernate.dialect.MySQLDialect</property>

<property name="transaction.factory_class">net.sf.hibernate.transaction.JTATransactionFactory</property>
<property name="jta.UserTransaction">UserTransaction</property>

<!-- mapping files -->
<mapping resource="air/tm/model/Domain.hbm.xml"/>
<mapping resource="air/tm/model/Group.hbm.xml"/>
<mapping resource="air/tm/model/Info.hbm.xml"/>
<mapping resource="air/tm/model/Mod.hbm.xml"/>
<mapping resource="air/tm/model/User.hbm.xml"/>
</session-factory>

</hibernate-configuration>


---*---

My Session0Bean.java:

Code:
/**
*
* @ejb.bean         name="Session0"
*                   jndi-name="ejb/tm/Session0"
*                   type="Stateless"
*
* @ejb.transaction  type="Required"
* @ejb.transaction-type type="Container"
*
*
* @ejb.resource-ref res-auth="Container"
*                   res-name="jdbc/MysqlDS"
*                   res-type="javax.sql.DataSource"
* @jboss.resource-ref res-ref-name="jdbc/MysqlDS"
*                     resource-name="MysqlDS"
*
* @jboss.container-configuration name="Standard Stateless SessionBean"
*/
public class Session0Bean implements SessionBean {
/**
* @ejb.interface-method view-type="remote"
*/
   
public boolean userLogin(Object user) {
boolean rv=false;

try {
Configuration cfg = new Configuration().configure();
SessionFactory sessions = cfg.buildSessionFactory();
Session sess = sessions.openSession();
//Transaction trans = sess.beginTransaction();
User u=new User();
u.setName("nev0");
sess.save(u);
//trans.commit();
sess.close();
   
} catch (Exception e) {
e.printStackTrace();
}
return rv;

}
   ...   
}


I hope you can help me: sofi


Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 10, 2003 11:51 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
Since you commented out the transaction handling, the session is not being flushed. Please see the FAQ.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 10, 2003 12:11 pm 
Newbie

Joined: Mon Nov 10, 2003 10:37 am
Posts: 3
Location: Hungary
Hi Gavin!
Thanks your reply, but I comented it out because I have to:
Code:
17:05:30,875 ERROR [STDERR] net.sf.hibernate.HibernateException: You cannot commit during a managed transaction!
Now, I hope that you can realy help me.
sofi


Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 10, 2003 12:16 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
Quote:
Please see the FAQ.


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