-->
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: Hibernate JPA persist() doesn't work!
PostPosted: Mon Dec 20, 2010 8:24 pm 
Newbie

Joined: Mon Dec 20, 2010 6:36 pm
Posts: 2
I tried following code Hibernate JPA

Code:
try {
            EntityTransaction tx = getEntityManager().getTransaction();
            tx.begin();
            getEntityManager().persist(entity);
            tx.commit();
        } catch (RuntimeException re) {
            throw re;
        }finally {
            getEntityManager().close();
            EntityManagerFactoryManager.getInstance().close();
        }

The Entity is NOT written into Oracle DB, there is NO ANY EXCEPTIONS!

My persistence.xml is
Code:
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="1.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd">
    <persistence-unit name="DataServices" transaction-type="RESOURCE_LOCAL">
        <provider>org.hibernate.ejb.HibernatePersistence</provider>
        <non-jta-data-source>jdbc/sbnDataSource</non-jta-data-source>
                                                      more classes....
        <class>govonca.lrc.moe.sbn.internal.jpa.Application</class>
                                                    more classes....
        <exclude-unlisted-classes>true</exclude-unlisted-classes>
        <properties>
            <property name="hibernate.dialect" value="org.hibernate.dialect.Oracle10gDialect" />
            <property name="hibernate.connection.autocommit" value="true" />
            <property name="hibernate.show_sql" value="true" />
        </properties>
    </persistence-unit>
</persistence>


Any ideas?? Thanks in advance!


Top
 Profile  
 
 Post subject: Re: Hibernate JPA persist() doesn't work!
PostPosted: Tue Dec 21, 2010 6:02 pm 
Regular
Regular

Joined: Wed Feb 15, 2006 9:09 pm
Posts: 76
There are only three things I can think of:

1) You think "entity" isn't already persistent, but in fact it is.
2) For some reason the class referenced by "entity" isn't being picked up during persistence unit initialization.
3) hibernate.connection.autocommit=true is mucking about with your explicit transaction demarcation. I've never used it personally, but it doesn't sound like a setting you want to enable if you're managing transactions explicitly like that.

Other than that I'm out of ideas :).


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.