-->
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: Problem with LOCK-ing data
PostPosted: Wed Sep 05, 2007 9:23 am 
Newbie

Joined: Fri Aug 31, 2007 9:56 am
Posts: 6
I have problem with locking some record from ORACLE 9i DB.

I create Entity Bean, Session Bean in JDeveloper 11g.
My Persistant_Unit is:

Code:
<persistence-unit name="HibernatePU">
        <provider>org.hibernate.ejb.HibernatePersistence</provider>
        <properties>
            <property name="hibernate.archive.autodetection"   value="class, hbm"/>
            <property name="hibernate.connection.driver_class" value="oracle.jdbc.driver.OracleDriver"/>
            <property name="hibernate.connection.url" value="jdbc:oracle:thin:@localhost:1521:XE"/>
            <property name="hibernate.connection.username" value="zoran"/>
            <property name="hibernate.connection.password" value="zoran"/>
            <!-- <property name="hibernate.show_sql" value="false"/> -->
            <property name="hibernate.dialect" value="org.hibernate.dialect.OracleDialect"/>
            <property name="hibernate.hbm2ddl.auto" value="create-drop"/>
        </properties>
</persistence-unit>



In Java class I wrote:

Code:

private EntityManagerFactory EntityManagerFactoryM = Persistence.createEntityManagerFactory("HibernatePU");

private EntityManager EntityManagerMesto;

EntityManagerMesto = EntityManagerFactoryM.createEntityManager();


    private void Transaction()
    {
        Mesto mestoTB = EntityManagerMesto.find(Mesto.class,1);
     
        EntityTransaction transactionM = EntityManagerMesto.getTransaction();
     
        transactionM.begin();     
           
        EntityManagerMesto.lock(mestoTB, LockModeType.WRITE);
     
        System.out.println("testEJB: " + mestoTB.getNaziv());
        }
       

       Private void ExitForm()
       {
          transactionM.rollback();
        }





I want to know if this is right code to LOCK one recored from ORACLE 9I and not to allow to anybody to change that row until I call function
ExitForm() --- transactionM.rollback()


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.