[Persistence, JBoss/CMP, Hibernate, Database] - Locking data
by zoran9707
I have problem with locking some record from ORACLE 9i DB.
I create Entity Bean, Session Bean in JDeveloper 11g.
My Persistant_Unit is:
| <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:
|
| 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()
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4081574#4081574
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4081574
18 years, 7 months
[JBoss Seam] - class cast exception using managed persistence context
by arussel
I am using jboss-seam-1.2.1.GA in jboss 4.0.5 .
I followed the doc 8.3.1 on using seam managed persistence and get the following error
when seam try to inject the entity manager:
Caused by: java.lang.ClassCastException: org.jboss.ejb3.entity.InjectedEntityManagerFactory
at org.jboss.seam.core.ManagedPersistenceContext.getEntityManagerFactoryFromJndiOrValueBinding(ManagedPersistenceContext.java:160)
at org.jboss.seam.core.ManagedPersistenceContext.initEntityManager(ManagedPersistenceContext.java:77)
at org.jboss.seam.core.ManagedPersistenceContext.getEntityManager(ManagedPersistenceContext.java:105)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.jboss.seam.util.Reflections.invoke(Reflections.java:20)
at org.jboss.seam.util.Reflections.invokeAndWrap(Reflections.java:123)
at org.jboss.seam.Component.callComponentMethod(Component.java:1834)
at org.jboss.seam.Component.unwrap(Component.java:1860)
at org.jboss.seam.Component.getInstance(Component.java:1657)
I am using a loader in jboss-app.xml and I can see the factory in jndi:
+- EntityManagerFactory (class: org.jnp.interfaces.NamingContext)
| +- foo (class: org.jboss.ejb3.entity.InjectedEntityManagerFactory)
any help welcome,
thanks
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4081568#4081568
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4081568
18 years, 7 months