[JBoss-user] [Persistence,JBoss/CMP, Hibernate, Database] - Re: Can't save data in database

2005-09-14 Thread altheaparker
I didn't use a hibernate.cfg.xml or hibernate.properties when running the 
application as an EAR using jboss, accessing hibernate classes with a stateless 
session bean. I made a HAR which is a basic archive (just like a jar except 
.har instead) and put hibernate-service.xml in the META-INF folder. Then put 
the HAR in an EAR and put the above store() method in an ejb. My 
hibernate-service.xml looks like this. (i think jboss forum adds unnecessary br 
tags(?))




java:test
org.hibernate.dialect.HSQLDialect
java:/hibernate/SessionFactory
org.hibernate.cache.HashtableCacheProvider




When I was NOT running the application as an EAR (not using ejb) I ran the 
hibernate documentation tutorial using hibernate.cfg.xml file. Of course I had 
set up the hypersonic db beforehand.



http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd";>





org.hsqldb.jdbcDriver
jdbc:hsqldb:C:\hsqldb\db4hibernate\test
sa

org.hibernate.dialect.HSQLDialect
true

 org.hibernate.transaction.JDBCTransactionFactory


 org.hibernate.cache.HashtableCacheProvider

update








View the original post : 
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3894683#3894683

Reply to the post : 
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3894683


---
SF.Net email is sponsored by:
Tame your development challenges with Apache's Geronimo App Server. Download
it for free - -and be entered to win a 42" plasma tv or your very own
Sony(tm)PSP.  Click here to play: http://sourceforge.net/geronimo.php
___
JBoss-user mailing list
JBoss-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jboss-user


[JBoss-user] [Persistence,JBoss/CMP, Hibernate, Database] - Re: Can't save data in database

2005-09-12 Thread vlokesh
Can you post your hibernate.cfg.xml file for reference. 

Regards.

Lokesh.

View the original post : 
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3894370#3894370

Reply to the post : 
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3894370


---
SF.Net email is Sponsored by the Better Software Conference & EXPO
September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA
Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
___
JBoss-user mailing list
JBoss-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jboss-user


[JBoss-user] [Persistence,JBoss/CMP, Hibernate, Database] - Re: Can't save data in database

2005-09-12 Thread altheaparker
I was having the same problem too, and for a day and a half nearly went out of 
my mind trying to figure out why the data wouldn't save! Then I realized it was 
simple - I forgot to add session.flush() after saving but before closing the 
session. With jboss you use a HAR and put it in an EAR. By putting the 
hibernate classes in a HAR along with hibernate-service.xml as I understand you 
don't configure hibernate anymore with the hibernate.cfg.xml or 
hibernate.properties files. You also don't build the SessionFactory either you 
reference it, and don't need to do the transactions yourself in the method but 
the container will do them for you -of course don't forget to put in the 
ejb-jar.xml that your method has a required container managed transaction :) I 
think jboss also sets up the transaction configuration for you too, so you 
don't need to configure that for hibernate either.

Here is my method:

  public void store(String title, Date theDate) throws EJBException
  {
   System.out.println("EventFacadeBean.store: entered in method");
   Session hsession = null;

   try
   {

 InitialContext ctx  = new InitialContext();
 SessionFactory factory = (SessionFactory) 
ctx.lookup("java:/hibernate/SessionFactory");
 hsession = factory.openSession();

 Event theEvent = new Event();
 theEvent.setTitle(title);
 theEvent.setDate(theDate);

 hsession.save(theEvent);

   } catch(Exception e) {
 System.out.println("Exception found. " + e.getMessage());
   } finally {
 if (hsession!=null){
   hsession.flush();
   hsession.close();
 }
}
System.out.println("EventFacadeBean.store: finished method");
  } 

View the original post : 
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3894326#3894326

Reply to the post : 
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3894326


---
SF.Net email is Sponsored by the Better Software Conference & EXPO
September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA
Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
___
JBoss-user mailing list
JBoss-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jboss-user


[JBoss-user] [Persistence,JBoss/CMP, Hibernate, Database] - Re: Can't save data in database

2005-08-31 Thread khoff999
 Here's a little more I found out: 

 During a save Hibernate is executing a method in class 
AbstractSaveEventListener that is testing whether a variable useIdentityColumn 
is true or false.  It's false in mine (I don't know why, I do have an indentity 
column defined).  It looks to me that the call to
  source.getActionQueue().execute(insert);
is being skipped.  I'm just guessing this in the path it needs to go down to 
execute the save.   There must be another configuration setting needed to make 
useIdentityColumn == true.
 

if (useIdentityColumn) {
   EntityIdentityInsertAction insert = new EntityIdentityInsertAction   
(values, entity, persister, source);
source.getActionQueue().execute(insert);
id = insert.getGeneratedId();
   persister.setIdentifier( entity, id, source.getEntityMode() );
   source.getPersistenceContext().checkUniqueness(id, persister, entity);
//source.getBatcher().executeBatch  (); //found another 
way to ensure that all batched joined inserts have been executed
}


View the original post : 
http://locahost:8080/index.html?module=bb&op=viewtopic&p=3892518#3892518

Reply to the post : 
http://locahost:8080/index.html?module=bb&op=posting&mode=reply&p=3892518


---
SF.Net email is Sponsored by the Better Software Conference & EXPO
September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA
Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
___
JBoss-user mailing list
JBoss-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jboss-user


[JBoss-user] [Persistence,JBoss/CMP, Hibernate, Database] - Re: Can't save data in database

2005-08-31 Thread khoff999
I've been having the same problem for 2 weeks.  Its so bad that my 
management told me to stop using Hibernate, but I keep playing with it hoping I 
can figure it out.  The problem has to be something stupid, but its equally as 
stupid that you can execute session.save() and not get an exception, or for 
that matter any intelligible DEBUG output.
  
   Maybe we can help each other on this (I think we better because no one has 
responded to my HIbernate Forum post in 2 weeks).  

Below is what I'm seeing in the console when I do a save.  Obviously the 
mapping is good,  it is calculating the generated identifer correctly (I 
already have a 0 & 1 in the table, so 2 is correct.What I'm not seeing is 
the SQL insert statement (ShowSQL is set to true).   

Do you see something similar?  I am trying to step through the Hibernate 
code, but it is painful process because it is often hard to tell hat the 
methods should return if they are working correctly. 


 14:02:52,828 DEBUG [SessionFactoryObjectFactory] JNDI lookup: 
hibernate/SessionFactory
14:02:52,828 DEBUG [SessionFactoryObjectFactory] lookup: 
uid=4028a02e060db29a01060db2a277
14:02:58,468 DEBUG [JDBCContext] successfully registered Synchronization
14:02:58,484 DEBUG [SessionImpl] opened session at timestamp: 11255113782
14:03:00,328 DEBUG [DefaultSaveOrUpdateEventListener] saving transient instance
14:03:00,328 DEBUG [AbstractBatcher] opening JDBC connection
14:03:00,343 DEBUG [IncrementGenerator] fetching initial value: select 
max(LEDGER_ID) from gl_Ledger
14:03:00,343 DEBUG [SQL] select max(LEDGER_ID) from gl_Ledger
14:03:02,328 DEBUG [IncrementGenerator] first free id: 2
14:03:02,343 DEBUG [AbstractSaveEventListener] generated identifier: 2, using 
strategy: org.hibernate.id.IncrementGenerator
14:03:02,359 DEBUG [AbstractSaveEventListener] saving 
[com.blackdog.gl.domain.Ledger#2]
14:03:10,281 DEBUG [SessionImpl] closing session
14:03:10,281 DEBUG [AbstractBatcher] closing JDBC connection (open 
PreparedStatements: 0, globally: 0) (open ResultSets: 0, globally: 0)
14:03:38,562 DEBUG [CacheSynchronization] transaction before completion callback
14:03:38,562 DEBUG [CacheSynchronization] automatically flushing session
14:03:38,562 DEBUG [SessionImpl] automatically flushing session
14:03:38,562 DEBUG [JDBCContext] before transaction completion
14:03:38,562 DEBUG [SessionImpl] before transaction completion
14:03:38,609 DEBUG [CacheSynchronization] transaction after completion 
callback, status: 3
14:03:38,609 DEBUG [JDBCContext] after transaction completion
14:03:38,609 DEBUG [SessionImpl] after transaction completion

View the original post : 
http://locahost:8080/index.html?module=bb&op=viewtopic&p=3892491#3892491

Reply to the post : 
http://locahost:8080/index.html?module=bb&op=posting&mode=reply&p=3892491


---
SF.Net email is Sponsored by the Better Software Conference & EXPO
September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA
Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
___
JBoss-user mailing list
JBoss-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jboss-user