JPA and @SecondaryTable
Suppose I have an object that is mapped across two tables using the @SecondaryTable annotation.
Suppose further that the primary table often contains records that do not have a corresponding secondary table record.
If I merge() this entity, having assigned it an @Id that is already present in the primary table, what should happen?
Under OpenJPA, I get an error, because OpenJPA tries to do a blind INSERT into both tables.
Under EclipseLink, I get the same error.
Hibernate apparently figures out that it should do an UPDATE on the primary table and an INSERT on the secondary table.
Does anyone know which is the correct behavior?
Thanks,
Laird
Try using http://www.compass-project.org/
Similar Messages
-
Stored procedure, EJB, JPA, and JavaServer Faces
Hi!
I am currently working on a Web application using EJB, JPA, and JavaServer Faces. A part of the
business logic is already stored in the database as stored procedures, so we need to call those
procedures (instead of named queries) through a EJB and represent the data on the web tier.
Where can I find an extensive tutorial using this technology? There is no such tutorial in the Oracle Learning Library.
Maybe somebody can provide a link and/or example.
Thanks in advance for your help!Hi,
http://download.oracle.com/docs/cd/B10464_05/web.904/b10313/queries.htm#1135305
For more help, see the TopLink / JPA forum
TopLink/JPA
Frank -
JPA and SQL Server 2005's Identity Don't Play Nice
I am hoping someone with a little more senior knowledge of JPASQL Server 2005 can point me in the right direction involving SQL Server 2005.
What I am discovering is JPA and SQL Server 2005 do not playing nice together when you use the IDENTITY capability for
a primary key. Let me explain. "...when using the IDENTITY as the generator type, the value for the identity field MAY NOT be
available BEFORE the entity data is saved in the database because typically it is generated when a record is committed."
My problem is this.
I have two separate entities using another entity, for example a car has a wheel and a truck has a wheel. I can go through the steps
of persisting the car and the wheel with no problem. My problem begins when I try to
find the wheel (by wheel description) for the truck. The query finds the wheel, but does not return the primary key for wheel.
Therefore, using the PK inside a query generates this error:
java.lang.IllegalArgumentException: An instance of a null PK has been incorrectly provided for this find operation. What has been my appraoch to get the entity to commit to the database is to use the following sequence for the Entity Manager.
entityManager.persist(wheel);
entityManager.flush(); I have assumed to this point this action would persist my data because I have been able to retrieve the PK immidately after these steps.
However, multiple actions taking place within the same transaction, appears to render the persist and flush steps useless. My initial thought
is to wrap the wheel creation within a new transaction so when the method/transaction completes, the data would be in the database. This
has not worked.
I hope I have explained this clear for others to follow. I apologize in advance if I have not. Any suggestions are greatly appreciated.I am hoping someone with a little more senior knowledge of JPASQL Server 2005 can point me in the right direction involving SQL Server 2005.
What I am discovering is JPA and SQL Server 2005 do not playing nice together when you use the IDENTITY capability for
a primary key. Let me explain. "...when using the IDENTITY as the generator type, the value for the identity field MAY NOT be
available BEFORE the entity data is saved in the database because typically it is generated when a record is committed."
My problem is this.
I have two separate entities using another entity, for example a car has a wheel and a truck has a wheel. I can go through the steps
of persisting the car and the wheel with no problem. My problem begins when I try to
find the wheel (by wheel description) for the truck. The query finds the wheel, but does not return the primary key for wheel.
Therefore, using the PK inside a query generates this error:
java.lang.IllegalArgumentException: An instance of a null PK has been incorrectly provided for this find operation. What has been my appraoch to get the entity to commit to the database is to use the following sequence for the Entity Manager.
entityManager.persist(wheel);
entityManager.flush(); I have assumed to this point this action would persist my data because I have been able to retrieve the PK immidately after these steps.
However, multiple actions taking place within the same transaction, appears to render the persist and flush steps useless. My initial thought
is to wrap the wheel creation within a new transaction so when the method/transaction completes, the data would be in the database. This
has not worked.
I hope I have explained this clear for others to follow. I apologize in advance if I have not. Any suggestions are greatly appreciated. -
JPA and CAF BO - are there any editors of the JPA data (like CAF)?
Hello!
As you know SAP invented some layer above JPA and called it CAF. There is a very convenient way to edit data in CAF.
But now I have to create a complex database scheme, also with CAF doesn't allow us to work with objects. So we can't use someObject.getChildren().
So my question is are there any editors of the JPA data (like it is done in CAF)?Hi Kirill,
at the beginning of our project at the end of 2009, we did a deep analysis of CAF since our architect vehemently suggested to use this framework.
First about the history and purpose of CAF: Initially, CAF was never meant to be a layer above CAF since CAF was invented in the time before EJB 3.0 and JPA standard where writing persistence with EJB 2.x CMP forced the developer to write pages of boiler plate code. This background was approved by SAP.
With upcoming of JPA, CAF ist mostly useless (except for very simply structured data) and prevents you from writing good software.
It is easy just to write @Entity, @Id and @OneToMany (for complex database schemes) and CAF forces you to use an ugly, imperformant database scheme (e.g. CAF uses mapping tables even for 1:n relationships, a clear antipattern!)
The CRUD-services generated with CAF are a pain, too. Usage of pessimistic locking is not up to date for web applications.
With your complex database schemes, you exceed the limit of CAF.
(We decided not to use CAF and did never regret this.)
Concerning your question: There is an "JPA Details" view in NWDS that might help you. It needs JPA Persistence facet on your project to work. Developed by SAP. For JPA beginners, it is a good cheat sheet for JPA annotations and their attributes.
You do not need more since a JPA POJO is easy to code.
Regards,
Rolf -
hi ,
How can i represent my DataBase View in JPA , and since each "Entity" should have an "@Id" how can i handle this on my views since some of them does not have a convenient ID field/fields , ThanksIn this situation I created @Id for one of the columns or created @IdClass from all view fields.
-
[NewBie] Not able to connect JPA and Hibernate ?
Hi,
In last few days I have read some tutorial and started doing JPA and Hibernate tutorials. But I am not able to make it work. Can some one please point out what is that I am doing wrong? Here are the details of what I am doing
I am using
IDE : Eclipse EE Indigo
Following jars
antlr-2.7.6.jar
commons-collections-3.2.jar
dom4j-1.6.1.jar
hibernate-annotations-3.4.0.GA.jar
hibernate-commons-annotations-3.1.0.GA.jar
hibernate-entitymanager-3.4.0.GA.jar
hibernate-jpa-2.0-api.jar
hibernate3-3.3.2.GA.jar
javaee-api-5.0-3.jar
javassist-3.9.0.GA.jar
junit-4.8.2.jar
log4j-1.2.12.jar
slf4j-api-1.6.1.jar
slf4j-simple-1.6.1.jar
sqljdbc.jar => For connecting to MS SQL Server database
junit-4.8.2 => For testing the application
The target runtime is set as JBoss 5.0 with jars of JBoss 6.0
Here is my persistence.xml. This file is under "src\META-INF"
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.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_2_0.xsd">
<persistence-unit name="JH1" transaction-type="RESOURCE_LOCAL">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<class>entity.Users</class>
<exclude-unlisted-classes>false</exclude-unlisted-classes>
<properties>
<property name="hibernate.dialect" value="org.hibernate.dialect.SQLServerDialect"/>
<property name="hibernate.show_sql" value="true"/>
<property name="javax.persistence.jdbc.url" value="jdbc:sqlserver://localhost:1433;databaseName=TempEPMUser"/>
<property name="javax.persistence.jdbc.user" value="user"/>
<property name="javax.persistence.jdbc.password" value="password"/>
<property name="javax.persistence.jdbc.driver" value="com.microsoft.sqlserver.jdbc.SQLServerDriver"/>
<property name="javax.persistence.transactionType" value="RESOURCE_LOCAL"/>
</properties>
</persistence-unit>
</persistence>
Here is the Users.java code. This is the entity class created using the context menu item JPA Entities from tables
package entity;
import java.io.Serializable;
import javax.persistence.*;
import java.sql.Timestamp;
import java.math.BigDecimal;
* The persistent class for the Users database table.
@Entity
public class Users implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy=GenerationType.AUTO)
@Column(name="Usr_UserID")
private long usr_UserID;
@Column(name="Usr_DeptId")
private BigDecimal usr_DeptId;
public Users() {
public long getUsr_UserID() {
return this.usr_UserID;
public void setUsr_UserID(long usr_UserID) {
this.usr_UserID = usr_UserID;
Here is the testing code TestUser.java
package testentity;
import java.util.List;
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.EntityTransaction;
import javax.persistence.Persistence;
import javax.persistence.PersistenceException;
import org.apache.log4j.BasicConfigurator;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import entity.Users;
public class TestUser {
private EntityManagerFactory emf;
private EntityManager em;
@Before
public void initEmfAndEm(){
BasicConfigurator.configure();
try {
emf = Persistence.createEntityManagerFactory("JH1");
} catch (PersistenceException pe) {
System.out.println(pe.getMessage());
em = emf.createEntityManager();
@After
public void cleanup() {
em.close();
@Test
public void emptyTest() {
EntityTransaction et = em.getTransaction();
et.begin();
@SuppressWarnings("unchecked")
final List<Users> listUser = em.createQuery("select usr_DeptID from Users").getResultList();
et.commit();
for (Users usr: listUser){
int depid = usr.getUsr_DeptId().intValue();
System.out.println("User Department id is "+depid);
When I execute the code I get following error message
java.lang.UnsupportedOperationException: The user must supply a JDBC connection
at org.hibernate.connection.UserSuppliedConnectionProvider.getConnection(UserSuppliedConnectionProvider.java:54)
at org.hibernate.jdbc.ConnectionManager.openConnection(ConnectionManager.java:446)
at org.hibernate.jdbc.ConnectionManager.getConnection(ConnectionManager.java:167)
at org.hibernate.jdbc.JDBCContext.connection(JDBCContext.java:142)
at org.hibernate.transaction.JDBCTransaction.begin(JDBCTransaction.java:85)
at org.hibernate.impl.SessionImpl.beginTransaction(SessionImpl.java:1354)
at org.hibernate.ejb.TransactionImpl.begin(TransactionImpl.java:38)
at testentity.TestUser.emptyTest(TestUser.java:42)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31)
at org.junit.runners.BlockJUnit4ClassRunner.runNotIgnored(BlockJUnit4ClassRunner.java:79)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:71)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:49)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)Hi,
Try following the JPA tutorials for WebLogic, JPA using EclipseLink or Hibernate will be the same if you stick to the specification. WebLogic 10.3.4.0 ships with a Java EE 6 compliant JPA 2.0 implementation in EclipseLink - you may want to give that a try.
http://wiki.eclipse.org/EclipseLink/Examples/JPA/WebLogic_Web_Tutorial
http://wiki.eclipse.org/EclipseLink/Examples/Distributed
I also have a JBoss 6 tutorial for getting JPA working as well.
BTW, your persistence unit is currently application managed - try switching to container managed - then most of your jar dependencies will go away as everything is already setup for you to do dependency injection via the container.
http://wiki.eclipse.org/EclipseLink/Examples/JPA/JBoss_Web_Tutorial
thank you
Michael O'Brien
http://www.eclipselink.org -
Hi people...
I working with JPA and Hibernate and i have a View in my Database and i need to map this View. It's this possible? Some have an example to show me?.
Thanks!I hope this link help you
http://forums.java.net/jive/message.jspa?messageID=244187
I�m having a similar problem, I�m developing using JPA and now I need to bring values from some views on database but I still don�t know how.I�m still Java jr and I didn�t understand clearly but I guess that the link can help you, and if it�s true please explain me. -
What are the relation between JPA and Hibernate, JPA and TopLink?
What are the relation between JPA and Hibernate, JPA and TopLink?
Can JPA instead of Hibernate and TopLink?The Java Persistence API (JPA) is the object relational mapping persistence
standard for Java. Hibernate and TopLink provide an Open source Object-relational mapping framework for Java.
They provide an implementation for the Java Persistence API. In my opinion, both Hibernate and TopLink provide support to JPA
and they can also be regarded as the complementary to JPA.
Let's wait to see other person's opinions. -
Set role with Java JPA and NativeSQL
Hi,
using 10g setting roles with Java JPA and NativeSQL works fine. After the upgrade to 11g the same commands will not work.
Ars ther any significant changes to set roles in 11g?
Regards
Siegwinsiegwin.port wrote:
using 10g setting roles with Java JPA and NativeSQL works fine. After the upgrade to 11g the same commands will not work.
Ars ther any significant changes to set roles in 11g?When I eval'd 11g, I did not notice any changes in setting my roles. I did notice a significant difference in Java. I cannot remember the JDK version change from 10g to 11g. We ended up settling back to 10g for other reasons. -
OC4J 10.1.3.2, JPA and Hibernate 3.2 Exception on Deployment
I can't get my simple web application to deploy in my standalone oc4j container. The European organization that I working for wants to use the new technologies out there. Part of the testing is getting oc4j working with hibernate. My web application works just fine with Toplink, but not with Hibernate3. The same web application in Tomcat works for both. The error that oc4j generates is shown below and really doesn't say much that I can do. I followed this blog instructions.
http://debupanda.blogspot.com/2007/01/using-hibernate-as-pluggable-ejb-3-jpa.html
2007-04-23 11:48:57.477 NOTIFICATION Starting application : TestJPA
2007-04-23 11:48:57.477 NOTIFICATION Initializing ClassLoader(s)
2007-04-23 11:48:57.477 NOTIFICATION Initializing EJB container
2007-04-23 11:48:57.477 NOTIFICATION Loading connector(s)
2007-04-23 11:48:57.524 NOTIFICATION Starting up resource adapters
2007-04-23 11:48:57.524 NOTIFICATION Initializing EJB sessions
2007-04-23 11:48:57.524 NOTIFICATION Committing ClassLoader(s)
2007-04-23 11:48:57.524 NOTIFICATION Initialize TestJPA begins...
2007-04-23 11:48:57.539 NOTIFICATION Initialize TestJPA ends...
2007-04-23 11:48:57.539 NOTIFICATION Started application : TestJPA
2007-04-23 11:48:57.555 NOTIFICATION Binding web application(s) to site default-
web-site begins...
2007-04-23 11:48:57.571 NOTIFICATION Binding TestJPA web-module for application
TestJPA to site default-web-site under context root jpa
07/04/23 11:48:57 oracle.oc4j.admin.internal.DeployerException: [TestJPA:TestJPA
] - Exception creating EntityManagerFactory using PersistenceProvider class org.
hibernate.ejb.HibernatePersistence for persistence unit TestPU.
07/04/23 11:48:57 at com.evermind.server.ejb.exception.DeploymentException
.exceptionCreatingEntityManagerFactory(DeploymentException.java:130)
07/04/23 11:48:57 at com.evermind.server.ejb.persistence.PersistenceUnitMa
nagerImpl.createContainerEntityManagerFactory(PersistenceUnitManagerImpl.java:19
7)
07/04/23 11:48:57 at com.evermind.server.ejb.persistence.PersistenceUnitMa
nagerImpl.initializePersistenceUnit(PersistenceUnitManagerImpl.java:159)
07/04/23 11:48:57 at com.evermind.server.ejb.persistence.PersistenceUnitMa
nagerImpl.initialize(PersistenceUnitManagerImpl.java:86)
07/04/23 11:48:57 at com.evermind.server.http.HttpApplication.<init>(HttpA
pplication.java:733)
07/04/23 11:48:57 at com.evermind.server.ApplicationStateRunning.getHttpAp
plication(ApplicationStateRunning.java:414)
07/04/23 11:48:57 at com.evermind.server.Application.getHttpApplication(Ap
plication.java:571)
07/04/23 11:48:57 at com.evermind.server.http.HttpSite$HttpApplicationRunT
imeReference.createHttpApplicationFromReference(HttpSite.java:1990)
07/04/23 11:48:57 at com.evermind.server.http.HttpSite$HttpApplicationRunT
imeReference.<init>(HttpSite.java:1909)
07/04/23 11:48:57 at com.evermind.server.http.HttpSite.addHttpApplication(
HttpSite.java:1606)
07/04/23 11:48:57 at oracle.oc4j.admin.internal.WebApplicationBinder.bindW
ebApp(WebApplicationBinder.java:238)
07/04/23 11:48:57 at oracle.oc4j.admin.internal.WebApplicationBinder.bindW
ebApp(WebApplicationBinder.java:99)
07/04/23 11:48:57 at oracle.oc4j.admin.internal.ApplicationDeployer.bindWe
bApp(ApplicationDeployer.java:547)
07/04/23 11:48:57 at oracle.oc4j.admin.internal.ApplicationDeployer.doDepl
oy(ApplicationDeployer.java:202)
07/04/23 11:48:57 at oracle.oc4j.admin.internal.DeployerBase.execute(Deplo
yerBase.java:93)
07/04/23 11:48:57 at oracle.oc4j.admin.jmx.server.mbeans.deploy.OC4JDeploy
erRunnable.doRun(OC4JDeployerRunnable.java:52)
07/04/23 11:48:57 at oracle.oc4j.admin.jmx.server.mbeans.deploy.DeployerRu
nnable.run(DeployerRunnable.java:81)
07/04/23 11:48:57 at com.evermind.util.ReleasableResourcePooledExecutor$My
Worker.run(ReleasableResourcePooledExecutor.java:298)
07/04/23 11:48:57 at java.lang.Thread.run(Unknown Source)
2007-04-23 11:48:57.726 NOTIFICATION Application Deployer for TestJPA FAILED.
2007-04-23 11:48:57.726 NOTIFICATION Application UnDeployer for TestJPA STARTS.
2007-04-23 11:48:57.742 NOTIFICATION Removing all web binding(s) for application
TestJPA from all web site(s)
07/04/23 11:48:57 SEVERE: ProgressObjectImpl.reportError [TestJPA:TestJPA] - Exc
eption creating EntityManagerFactory using PersistenceProvider class org.hiberna
te.ejb.HibernatePersistence for persistence unit TestPU.oracle.oc4j.admin.jmx.sh
ared.exceptions.InternalException: [TestJPA:TestJPA] - Exception creating Entity
ManagerFactory using PersistenceProvider class org.hibernate.ejb.HibernatePersis
tence for persistence unit TestPU.
at oracle.oc4j.admin.jmx.shared.deploy.NotificationUserData.<init>(Notif
icationUserData.java:107)
at oracle.oc4j.admin.internal.Notifier.reportError(Notifier.java:429)
at oracle.oc4j.admin.internal.DeployerBase.execute(DeployerBase.java:123
at oracle.oc4j.admin.jmx.server.mbeans.deploy.OC4JDeployerRunnable.doRun
(OC4JDeployerRunnable.java:52)
at oracle.oc4j.admin.jmx.server.mbeans.deploy.DeployerRunnable.run(Deplo
yerRunnable.java:81)
at com.evermind.util.ReleasableResourcePooledExecutor$MyWorker.run(Relea
sableResourcePooledExecutor.java:298)
at java.lang.Thread.run(Unknown Source)
Caused by: oracle.oc4j.admin.internal.DeployerException: [TestJPA:TestJPA] - Exc
eption creating EntityManagerFactory using PersistenceProvider class org.hiberna
te.ejb.HibernatePersistence for persistence unit TestPU.
at com.evermind.server.ejb.exception.DeploymentException.exceptionCreati
ngEntityManagerFactory(DeploymentException.java:130)
at com.evermind.server.ejb.persistence.PersistenceUnitManagerImpl.create
ContainerEntityManagerFactory(PersistenceUnitManagerImpl.java:197)
at com.evermind.server.ejb.persistence.PersistenceUnitManagerImpl.initia
lizePersistenceUnit(PersistenceUnitManagerImpl.java:159)
at com.evermind.server.ejb.persistence.PersistenceUnitManagerImpl.initia
lize(PersistenceUnitManagerImpl.java:86)
at com.evermind.server.http.HttpApplication.<init>(HttpApplication.java:
733)
at com.evermind.server.ApplicationStateRunning.getHttpApplication(Applic
ationStateRunning.java:414)
at com.evermind.server.Application.getHttpApplication(Application.java:5
71)
at com.evermind.server.http.HttpSite$HttpApplicationRunTimeReference.cre
ateHttpApplicationFromReference(HttpSite.java:1990)
at com.evermind.server.http.HttpSite$HttpApplicationRunTimeReference.<in
it>(HttpSite.java:1909)
at com.evermind.server.http.HttpSite.addHttpApplication(HttpSite.java:16
06)
at oracle.oc4j.admin.internal.WebApplicationBinder.bindWebApp(WebApplica
tionBinder.java:238)
at oracle.oc4j.admin.internal.WebApplicationBinder.bindWebApp(WebApplica
tionBinder.java:99)
at oracle.oc4j.admin.internal.ApplicationDeployer.bindWebApp(Application
Deployer.java:547)
at oracle.oc4j.admin.internal.ApplicationDeployer.doDeploy(ApplicationDe
ployer.java:202)
at oracle.oc4j.admin.internal.DeployerBase.execute(DeployerBase.java:93)
... 4 more
2007-04-23 11:48:58.225 NOTIFICATION Application UnDeployer for TestJPA COMPLETE
S.
07/04/23 11:48:58 WARNING: DeployerRunnable.run [TestJPA:TestJPA] - Exception cr
eating EntityManagerFactory using PersistenceProvider class org.hibernate.ejb.Hi
bernatePersistence for persistence unit TestPU.oracle.oc4j.admin.internal.Deploy
erException: [TestJPA:TestJPA] - Exception creating EntityManagerFactory using P
ersistenceProvider class org.hibernate.ejb.HibernatePersistence for persistence
unit TestPU.
at oracle.oc4j.admin.internal.DeployerBase.execute(DeployerBase.java:126
at oracle.oc4j.admin.jmx.server.mbeans.deploy.OC4JDeployerRunnable.doRun
(OC4JDeployerRunnable.java:52)
at oracle.oc4j.admin.jmx.server.mbeans.deploy.DeployerRunnable.run(Deplo
yerRunnable.java:81)
at com.evermind.util.ReleasableResourcePooledExecutor$MyWorker.run(Relea
sableResourcePooledExecutor.java:298)
at java.lang.Thread.run(Unknown Source)I am not using JDeveloper, the project was created in Netbeans 5.5. I only use the WAR created and Deploy it using the web administration of Oracle 10.1.3.2
-
Dear experts,
I have a WD application with EJB model. I have faced strange JPA exception (I am using SAP JPA implementation).
This is 2 Entities with relationship
@Entity
@Table( schema = "dbo", name = "class")
public class ClassEntity {
private Long id;
@Id
@Column(name="id")
@GeneratedValue(strategy= GenerationType.IDENTITY)
public Long getId() {
return id;
public void setId(Long id) {
this.id = id;
private Collection<ClassAttributeEntity> classAttributesById;
@OneToMany(mappedBy = "classByClassId", fetch=FetchType.LAZY)
public Collection<ClassAttributeEntity> getClassAttributesById() {
return classAttributesById;
public void setClassAttributesById(Collection<ClassAttributeEntity> classAttributesById) {
this.classAttributesById = classAttributesById;
@Entity
@Table( schema = "dbo", name = "class_attribute")
public class ClassAttributeEntity{
private Long id;
@Id
@Column(name="id")
@GeneratedValue(strategy= GenerationType.IDENTITY)
public Long getId() {
return id;
public void setId(Long id) {
this.id = id;
private ClassEntity classByClassId;
@ManyToOne
@JoinColumn(name = "class_id", referencedColumnName = "id")
public ClassEntity getClassByClassId() {
return classByClassId;
public void setClassByClassId(ClassEntity classByClassId) {
this.classByClassId = classByClassId;
I want to execute JPQL query
"SELECT c FROM ClassEntity c"
; But I get this exception:
javax.persistence.PersistenceException: The relationship >>classAttributesById<< of entity {test.ClassEntity(id=1686)}cannot be loaded because the entity is detached
I can overcome it using EAGER loading -
@OneToMany(mappedBy = "classByClassId", fetch=FetchType.EAGER)
, but I really dont need ClassAttributes in this situation! I have many thousands of classes and eager loading provides extremly poor perfomance. What can I do with this problem?
Thanks in advance for any advice.Hi Andrey,
I assume you are getting the exception if you atempt to access "classAttributesById" ouside the transaction, in which you executed the query, i.e. after the persistence context, in which the query has been executed is closed.
You have got to make sure that all entities you need to access are read as long as the persistence context executing the query is still open.
How to address this depends a bit on whether you need to access all related entites or only some.
If you need to access the relationship "classAttributesById" for only some instances of "ClassEntity", you could for example call size() on "classAttributesById" for these selected instances of "ClassEntity" (within the same transaction/persistence context".
If you need to access all related entities, theoretically, fetchType = EAGER would be the right choice. However, as you have observed, SAP JPA can't handle this efficiently at the time beeing. Therefore,
I'd rather suggest that you firstly load all related attributes with a query
"SELECT ca FROM ClassAttributeEntity ca"
and secondly load the "ClassEntity"s
"SELECT c FROM ClassEntity c"
this should execute efficiently.
Sorry for the inconvenience.
-Adrian -
I am experiencing an exception indicating a missing mapping for a field. My problem is that I have a mapping! I suspect the problem has something to do with the fact the field in question is also the @PrimaryKeyJoinColumn. Am I doing something wrong or is this a bug in the refresh() method code since the find() method works with no problem? Thanks in advance.
Code and log excerpts follow:
Calling Code...
TaxableDescription description = em.find( TaxableDescription.class, cusip );
if (refreshEntity) {
{color:#ff0000}em.refresh( description );{color}
Entity Code..
@Entity
{color:#ff0000}@Table( name="f_ISSUE" )
@SecondaryTable(
name="f_COUPON_INFO",
pkJoinColumns=@PrimaryKeyJoinColumn(
referencedColumnName="issue_id", name="issue_id"
){color}
@NamedQueries({
@NamedQuery(
name="TaxableDescription.findByCusip",
query="SELECT d FROM TaxableDescription d WHERE d.cusip = :cusip"
public class TaxableDescription
extends Description implements Serializable
private long issueID;
private long fkIssueID;
private String interestFrequencyCode;
private Date nextCallDate;
private double nextCallPrice;
private Date parCallDate;
private double parCallPrice;
private boolean defaulted;
private String variableCouponType;
//@Id
@Column( name="issue_id", table="f_ISSUE" )
public long getIssueID() {
return issueID;
public void setIssueID( long issueID ) {
this.issueID = issueID;
@Override
@Id
@Column( name="CUSIP_nbr" )
public String getCusip() {
return super.getCusip();
@Override
public void setCusip(String cusip) {
super.setCusip(cusip);
@Override
@Column( name="maturity", updatable=false, insertable=false )
@Temporal(TemporalType.DATE)
public Date getMaturity() {
return super.getMaturity();
@Override
public void setMaturity(Date maturity) {
super.setMaturity(maturity);
{color:#ff0000} @Column( table="f_COUPON_INFO", name="issue_id", insertable=false, updatable=false )
{color} public long getFkIssueID() {
return fkIssueID;
public void setFkIssueID( long fkIssueID ) {
this.fkIssueID = fkIssueID;
@Override
@Column( table="f_COUPON_INFO", name="coupon", updatable=false, insertable=false )
public double getCoupon() {
return super.getCoupon();
@Override
public void setCoupon(double coupon) {
super.setCoupon( coupon );
@Column( table="f_COUPON_INFO", name="interest_frequency", updatable=false, insertable=false )
public String getInterestFrequencyCode() {
return interestFrequencyCode;
public void setInterestFrequencyCode( String interestFrequencyCode ) {
this.interestFrequencyCode = interestFrequencyCode;
@Override
@Column( table="f_COUPON_INFO", name="dated_date", updatable=false, insertable=false )
@Temporal( TemporalType.DATE )
public Date getDatedDate() {
return super.getDatedDate();
@Override
public void setDatedDate(Date datedDate) {
super.setDatedDate(datedDate);
@Override
@Column( table="f_COUPON_INFO", name="first_interest_date", updatable=false, insertable=false )
@Temporal( TemporalType.DATE )
public Date getFirstInterestDate() {
return super.getFirstInterestDate();
@Override
public void setFirstInterestDate(Date firstInterestDate) {
super.setFirstInterestDate(firstInterestDate);
@Column( name="next_call_date", updatable=false, insertable=false )
@Temporal( TemporalType.DATE )
protected Date getNextCallDate() {
return nextCallDate;
protected void setNextCallDate( Date date ) {
this.nextCallDate = date;
@Column( name="next_call_rate", updatable=false, insertable=false )
protected double getNextCallPrice() {
return nextCallPrice;
protected void setNextCallPrice( double value ) {
this.nextCallPrice = value;
@Column( name="par_call_date", updatable=false, insertable=false )
@Temporal( TemporalType.DATE )
protected Date getParCallDate() {
return parCallDate;
protected void setParCallDate( Date date ) {
this.parCallDate = date;
@Column( name="par_call_rate", updatable=false, insertable=false )
protected double getParCallPrice() {
return parCallPrice;
protected void setParCallPrice( double value ) {
this.parCallPrice = value;
@Column( name="moodys_code", updatable=false, insertable=false )
public Integer getIntegerMoodysCode() {
return super.getMoodysCode();
public void setIntegerMoodysCode(Integer moodysCode) {
super.setMoodysCode( moodysCode != null ? moodysCode : 99 );
@Column( name="s_p_code", updatable=false, insertable=false )
public Integer getIntegerSpCode() {
return super.getSpCode();
public void setIntegerSpCode(Integer spCode) {
super.setSpCode( spCode != null ? spCode : 99 );
@Column( name="fitch_code", updatable=false, insertable=false )
public Integer getIntegerFitchCode() {
return super.getFitchCode();
public void setIntegerFitchCode(Integer fitchCode) {
super.setFitchCode( fitchCode != null ? fitchCode : 99 );
@Override
@Column( name="principal_amt", updatable=false, insertable=false )
public double getPrincipalAmount() {
return super.getPrincipalAmount();
@Override
public void setPrincipalAmount(double principalAmount) {
super.setPrincipalAmount(principalAmount);
@Transient
public boolean getDefaulted() {
return defaulted;
@Transient
public boolean isDefaulted() {
return defaulted;
public void setDefaulted( boolean defaulted ) {
this.defaulted = defaulted;
@Column( name="defaulted", updatable=false, insertable=false )
public String getDefaultedFlag() {
return defaulted ? "Y" : "N";
public void setDefaultedFlag( String defaultedFlag ) {
this.defaulted = "Y".equalsIgnoreCase( defaultedFlag );
@Column( table="f_COUPON_INFO", name="coupon_change_indicator", updatable=false, insertable=false )
public String getVariableCouponType() {
return variableCouponType;
public void setVariableCouponType( String variableCouponType ) {
this.variableCouponType = variableCouponType;
@OneToMany( targetEntity=com.bondtrac.entities.TaxableCouponStepEntity.class )
@JoinTable(
name="f_CHANGE_SCHEDULE",
joinColumns=@JoinColumn( name="issue_id", referencedColumnName="issue_id" )
public List getCouponSteps() {
return super.getCouponStepSchedule();
public void setCouponSteps( List couponSteps ) {
super.setCouponStepSchedule( couponSteps );
@PostLoad
private void postLoad() {
if ( interestFrequencyCode != null &&
interestFrequencyCode.length() > 0 )
int intFreq = 2;
try {
intFreq = Integer.parseInt( interestFrequencyCode );
catch ( Exception e ) {}
if ( intFreq <= 0 ) intFreq = 2;
super.setInterestFrequency( intFreq );
else {
super.setInterestFrequency( 2 );
if ( nextCallDate != null || parCallDate != null ) {
CallSchedule _callSchedule = super.getCallSchedule();
if ( _callSchedule == null ) {
_callSchedule = new CallSchedule();
super.setCallSchedule( _callSchedule );
if ( nextCallDate != null ) {
_callSchedule.addCall( nextCallDate, nextCallPrice );
if ( parCallDate != null ) {
_callSchedule.addCall( parCallDate, parCallPrice );
@PrePersist
@PreUpdate
private void preUpdate() {
switch ( super.getInterestFrequency() ) {
case 2 : interestFrequencyCode = "2"; break;
case 1 : interestFrequencyCode = "1"; break;
case 4 : interestFrequencyCode = "4"; break;
case 12 : interestFrequencyCode = "12"; break;
case 99 : interestFrequencyCode = "99"; break;
default : interestFrequencyCode = "2"; break;
nextCallDate = null;
nextCallPrice = 0.0;
parCallDate = null;
parCallPrice = 0.0;
CallSchedule _callSchedule = super.getCallSchedule();
if ( _callSchedule != null ) {
Call call = _callSchedule.getNextCall();
if ( call != null ) {
nextCallDate = call.getDate();
nextCallPrice = call.getAmount();
call = _callSchedule.getNextParCall();
if ( call != null ) {
parCallDate = call.getDate();
parCallPrice = call.getAmount();
@Override
public int hashCode() {
return cusip != null ? cusip.hashCode() : 0;
@Override
public boolean equals( Object o ) {
if ( !( o instanceof TaxableDescription ) ) return false;
TaxableDescription otherDescription = (TaxableDescription)o;
if ( cusip == otherDescription.cusip ) return true;
if ( cusip != null ) return cusip.equals( otherDescription.cusip );
return false;
Server log entry...
[#|2008-11-20T17:41:42.389-0600|WARNING|sun-appserver9.1|oracle.toplink.essentials.session.file:/opt/SUNWappserver/domains/domain1/applications/j2ee-apps/Bondtrac-EE/Bondtrac-EE-pu.jar-BondtracPU|_ThreadID=36;_ThreadName=p: thread-pool-1; w: 44;_RequestID=5b92f658-e52c-4b83-aafc-454a052fc30b;|
Local Exception Stack:
Exception [TOPLINK-45] (Oracle TopLink Essentials - 2.0.1 (Build b04-fcs (04/11/2008))): oracle.toplink.essentials.exceptions.DescriptorException
{color:#ff0000}Exception Description: Missing mapping for field [f_COUPON_INFO.issue_id].{color}
Descriptor: RelationalDescriptor(com.bondtrac.entities.TaxableDescription --> [DatabaseTable(f_ISSUE), DatabaseTable(f_COUPON_INFO)])
at oracle.toplink.essentials.exceptions.DescriptorException.missingMappingForField(DescriptorException.java:901)
at oracle.toplink.essentials.internal.descriptors.ObjectBuilder.addPrimaryKeyForNonDefaultTable(ObjectBuilder.java:154)
at oracle.toplink.essentials.internal.descriptors.ObjectBuilder.buildRowForTranslation(ObjectBuilder.java:899)
at oracle.toplink.essentials.queryframework.ReadObjectQuery.prepareForExecution(ReadObjectQuery.java:502)
at oracle.toplink.essentials.queryframework.DatabaseQuery.execute(DatabaseQuery.java:622)
at oracle.toplink.essentials.queryframework.ObjectLevelReadQuery.execute(ObjectLevelReadQuery.java:692)
at oracle.toplink.essentials.queryframework.ObjectLevelReadQuery.executeInUnitOfWork(ObjectLevelReadQuery.java:746)
at oracle.toplink.essentials.internal.sessions.UnitOfWorkImpl.internalExecuteQuery(UnitOfWorkImpl.java:2233)
at oracle.toplink.essentials.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:952)
at oracle.toplink.essentials.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:909)
at oracle.toplink.essentials.internal.ejb.cmp3.base.EntityManagerImpl.refresh(EntityManagerImpl.java:389)
at com.sun.enterprise.util.EntityManagerWrapper.refresh(EntityManagerWrapper.java:511)
at com.bondtrac.ejb.DescriptionDAOBean.getDescription(DescriptionDAOBean.java:76)
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:597)
at com.sun.enterprise.security.application.EJBSecurityManager.runMethod(EJBSecurityManager.java:1067)
at com.sun.enterprise.security.SecurityUtil.invoke(SecurityUtil.java:176)
at com.sun.ejb.containers.BaseContainer.invokeTargetBeanMethod(BaseContainer.java:2895)
at com.sun.ejb.containers.BaseContainer.intercept(BaseContainer.java:3986)
at com.sun.ejb.containers.EJBLocalObjectInvocationHandler.invoke(EJBLocalObjectInvocationHandler.java:197)
at com.sun.ejb.containers.EJBLocalObjectInvocationHandlerDelegate.invoke(EJBLocalObjectInvocationHandlerDelegate.java:83)
at $Proxy197.getDescription(Unknown Source)
at com.bondtrac.offeringprocessor.OfferingProcessorBean.process(OfferingProcessorBean.java:1373)
at com.bondtrac.offeringprocessor.OfferingProcessorBean.processOfferingEntity(OfferingProcessorBean.java:642)
at com.bondtrac.offeringprocessor.OfferingProcessorBean.calculateOfferings(OfferingProcessorBean.java:926)
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:597)
at com.sun.enterprise.security.application.EJBSecurityManager.runMethod(EJBSecurityManager.java:1067)
at com.sun.enterprise.security.SecurityUtil.invoke(SecurityUtil.java:176)
at com.sun.ejb.containers.BaseContainer.invokeTargetBeanMethod(BaseContainer.java:2895)
at com.sun.ejb.containers.BaseContainer.intercept(BaseContainer.java:3986)
at com.sun.ejb.containers.EJBObjectInvocationHandler.invoke(EJBObjectInvocationHandler.java:203)
at com.sun.ejb.containers.EJBObjectInvocationHandlerDelegate.invoke(EJBObjectInvocationHandlerDelegate.java:77)
at $Proxy198.calculateOfferings(Unknown Source)
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:597)
at com.sun.corba.ee.impl.presentation.rmi.ReflectiveTie._invoke(ReflectiveTie.java:154)
at com.sun.corba.ee.impl.protocol.CorbaServerRequestDispatcherImpl.dispatchToServant(CorbaServerRequestDispatcherImpl.java:687)
at com.sun.corba.ee.impl.protocol.CorbaServerRequestDispatcherImpl.dispatch(CorbaServerRequestDispatcherImpl.java:227)
at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.handleRequestRequest(CorbaMessageMediatorImpl.java:1846)
at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.handleRequest(CorbaMessageMediatorImpl.java:1706)
at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.handleInput(CorbaMessageMediatorImpl.java:1088)
at com.sun.corba.ee.impl.protocol.giopmsgheaders.RequestMessage_1_2.callback(RequestMessage_1_2.java:223)
at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.handleRequest(CorbaMessageMediatorImpl.java:806)
at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.dispatch(CorbaMessageMediatorImpl.java:563)
at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.doWork(CorbaMessageMediatorImpl.java:2567)
at com.sun.corba.ee.impl.orbutil.threadpool.ThreadPoolImpl$WorkerThread.run(ThreadPoolImpl.java:555)
|#]What database are you using? My guess is that the database you are using returns field names in Uppercase. While the database may not be case sensitive, most databases will convert the field names to either all upper or lower case when returning the metadata - which associates the fields to the values. In this case, it is looking for a value for "issue_id" in the returned results, when I suspect that the database returned a value for "ISSUE_ID". Try having your column names match what the database will return and see if you still get problems.
The other part to this problem is that it does not appear mapped correctly. The primarykeyJoincolumn isn't using primary key fields (CUSIP_nbr is specified as the id), and you have a join table also using the "issue_id" field, so it really should be the id. Either way, the Secondary table is specifying f_ISSUE.issue_id to be a foreign key to f_COUPON_INFO.issue_id, and so the getFkIssueID annotation should be marked insertable=true, updateable =true and the annotation on getIssueID marked insertable=false, updatable=false,since it is set through the f_COUPON_INFO.issue_id field. Fixing this will also likely resolve the issue - the error says it can't find a mapping for the f_COUPON_INFO.issue_id but from looking at the code, what I believe it means is that it can't find a writable mapping. Reading this over again, it looks very confusing but I dont know if I can explain it much better. The field f_COUPON_INFO needs to be writeable and set by the application because you have marked it as controlling the field in f_ISSUE. The field in f_ISSUE needs to be read only, because the value is set/controlled by the value in f_COUPON_INFO.
Best Regards,
Chris -
Deployement problem in oc4j with hibernate + JPA and Spring
Dear All,
From last 2 days I am facing a problem in deployment of our application in oc4j client of oracle app server.
I am getting the following exception
Operation failed with error: [mkclsets:mkclsets] - Exception creating EntityManagerFactory using PersistenceProvider class oracle.toplink.essentials.ejb.cmp3.EntityManagerFactoryProvider for persistence unit mkclsetsPersistenceUnit.When I am deploying the same application in tomcat app server its working fine. But I am unable to deploy the same in oc4j.
I am using the following technologies
Spring 2.0
Struts 2.0
Hibernate 3.3
JPA 1.0
OC4J 10.1.3.3.0
IDE : my eclipse 6.0
My persistence.xml
<persistence 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"
version="1.0">
<persistence-unit name="mkclsetsPersistenceUnit" transaction-type="RESOURCE_LOCAL">
<!-- jta-data-source>mkclDS</jta-data-source-->
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<!-- properties>
<property name="hibernate.dialect" value="org.hibernate.dialect.Oracle10gDialect"/>
<property name="hibernate.transaction.manager_lookup_class" value="org.hibernate.transaction.OC4JTransactionManager"/>
</properties-->
</persistence-unit>
</persistence>Datasource-context.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.0.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd">
<bean class="org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor" lazy-init="true"/>
<!-- following code is for using oracle -->
<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource" lazy-init="true">
<property name="driverClassName">
<value>oracle.jdbc.driver.OracleDriver</value>
</property>
<property name="url">
<value>jdbc:oracle:thin:@//xxxx.xxxx.xxxx.xxxx:1521/mydb</value>
</property>
<property name="username">
<value>tpsadmin</value>
</property>
<property name="password">
<value>tpsadmin</value>
</property>
</bean>
<bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean" lazy-init="true">
<property name="persistenceUnitName" value="mkclsetsPersistenceUnit"/>
<property name="dataSource" ref="dataSource"/>
<property name="jpaVendorAdapter">
<bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter" lazy-init="true">
<property name="database" value="ORACLE"/>
<property name="showSql" value="true"/>
</bean>
</property>
</bean>
<bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager" lazy-init="true">
<property name="entityManagerFactory" ref="entityManagerFactory"></property>
</bean>
<tx:annotation-driven transaction-manager="transactionManager"/>
</beans>Server.xml (oc4j/j2ee/home/config)
<?xml version="1.0"?>
<application-server xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://xmlns.oracle.com/oracleas/schema/application-server-10_1.xsd" application-directory="../applications"
check-for-updates="adminClientOnly"
deployment-directory="../application-deployments"
connector-directory="../connectors"
schema-major-version="10" schema-minor-version="0" >
<shared-library name="global.libraries" version="1.0" library-compatible="true">
<code-source path="../applib"/>
</shared-library>
<shared-library name="global.tag.libraries" version="1.0" library-compatible="true">
<code-source path="../../home/jsp/lib/taglib/"/>
<code-source path="../../../j2ee/home/jsp/lib/taglib/"/>
<code-source path="../../../lib/dsv2.jar"/>
<import-shared-library name="oracle.xml"/>
<import-shared-library name="oracle.jdbc"/>
<import-shared-library name="oracle.cache"/>
<import-shared-library name="soap"/>
</shared-library>
<shared-library name="oracle.persistence" version="1.0" library-compatible="true">
<code-source path="../../../toplink/jlib/toplink-essentials.jar"/>
<import-shared-library name="oracle.jdbc"/>
</shared-library>
<shared-library name="hibernatejpa" version="1.0">
<code-source path="ejb3-persistence.jar"/>
<code-source path="hibernate3.jar"/>
<code-source path="hibernate-annotations.jar"/>
<code-source path="hibernate-commons-annotations.jar"/>
<code-source path="hibernate-entitymanager.jar"/>
<code-source path="jboss-archive-browsing.jar"/>
<code-source path="jta.jar"/>
</shared-library>
<shared-library name="db" version="1.0">
<code-source path="ojdbc14.jar"/>
</shared-library>
<shared-library name="displaytab" version="1.0">
<code-source path="commons-beanutils-1.7.0.jar"/>
<code-source path="commons-lang-2.3.jar"/>
<code-source path="displaytag-1.1.1.jar"/>
</shared-library>
<shared-library name="ehCache" version="1.0">
<code-source path="backport-util-concurrent.jar"/>
<code-source path="ehcache-1.4.0-beta2.jar"/>
<code-source path="jsr107cache-1.0.jar"/>
</shared-library>
<shared-library name="json" version="1.0">
<code-source path="ezmorph-1.0.4.jar"/>
<code-source path="json.jar"/>
</shared-library>
<shared-library name="other_sets" version="1.0">
<code-source path="commons-fileupload-1.1.jar"/>
<code-source path="dom4j-1.6.1.jar"/>
<code-source path="dwr.jar"/>
<code-source path="javassist.jar"/>
<code-source path="log4j-1.2.13.jar"/>
</shared-library>
<shared-library name="spring2" version="1.0">
<code-source path="aspectjrt.jar"/>
<code-source path="aspectjweaver.jar"/>
<code-source path="cglib-nodep-2.1_3.jar"/>
<code-source path="spring.jar"/>
</shared-library>
<shared-library name="struts2" version="1.0">
<code-source path="antlr-2.7.2.jar"/>
<code-source path="commons-collections.jar"/>
<code-source path="commons-io-1.1.jar"/>
<code-source path="commons-logging-1.0.4.jar"/>
<code-source path="freemarker-2.3.8.jar"/>
<code-source path="ognl-2.6.11.jar"/>
<code-source path="struts2-core-2.0.9.jar"/>
<code-source path="struts2-spring-plugin-2.0.9.jar"/>
<code-source path="xwork-2.0.4.jar"/>
</shared-library>
<rmi-config path="./rmi.xml" />
<jms-config path="./jms.xml" />
<javacache-config path="../../../javacache/admin/javacache.xml" />
<j2ee-logging-config path="./j2ee-logging.xml" />
<log>
<file path="../log/server.log" />
</log>
<java-compiler name="javac" in-process="false" options="-J-Xmx1024m -encoding UTF8" extdirs="C:\Program Files\Java\jdk1.5.0_07\jre\lib\ext" />
<global-application name="default" path="application.xml" parent="system" start="true" />
<application name="javasso" path="../../home/applications/javasso.ear" parent="default" start="false" />
<application name="ascontrol" path="../../home/applications/ascontrol.ear" parent="system" start="true" />
<application name="Test" path="../applications\Test.ear" parent="default" start="true" />
<application name="OraTest" path="../applications\OraTest.ear" parent="default" start="true" />
<global-web-app-config path="global-web-application.xml" />
<transaction-manager-config path="transaction-manager.xml" />
<web-site default="true" path="./default-web-site.xml" />
<cluster id="6745699755968" />
</application-server>Orion-application.xml (oc4j/j2ee/home/config)
<?xml version="1.0"?>
<orion-application xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://xmlns.oracle.com/oracleas/schema/orion-application-10_0.xsd" deployment-version="10.1.3.1.0" default-data-source="jdbc/OracleDS" component-classification="external"
schema-major-version="10" schema-minor-version="0" >
<imported-shared-libraries>
<import-shared-library name="hibernatejpa"/>
<import-shared-library name="db"/>
<import-shared-library name="displaytab"/>
<import-shared-library name="ehCache"/>
<import-shared-library name="json"/>
<import-shared-library name="other_sets"/>
<import-shared-library name="spring2"/>
<import-shared-library name="struts2"/>
</imported-shared-libraries>
</orion-application>Please help to deploy my application, I created one application with struts2 and spring2 and that is working fine, but when I try to add JPA with hibernate 3.3 I am unable to deploy it.
Thanks a lot in advance.
With best regards,
IshaanHi,
Thank you very much for your reply. the previous Exception has gone but now I get the following one.
Exception: NoClassDefFoundError: Missing class: org.dom4j.DocumentException Dependent class: org.hibernate.ejb.HibernatePersistence Loader: hibernatejpa:1.0 Code-Source: /C:/oracle123/j2ee/home/shared-lib/hibernatejpa/1.0/hibernate-entitymanager.jar Configuration: in /C:/oracle123/j2ee/home/config/server.xml The missing class is available from the following locations: 1. Code-Source: /C:/oracle123/j2ee/home/shared-lib/other_sets/1.0/dom4j-1.6.1.jar (from in /C:/oracle123/j2ee/home/config/server.xml) This code-source is available in loader other_sets:1.0.
[Jun 2, 2008 10:57:17 AM] Operation failed with error: Missing class: org.dom4j.DocumentException Dependent class: org.hibernate.ejb.HibernatePersistence Loader: hibernatejpa:1.0 Code-Source: /C:/oracle123/j2ee/home/shared-lib/hibernatejpa/1.0/hibernate-entitymanager.jar Configuration: in /C:/oracle123/j2ee/home/config/server.xml The missing class is available from the following locations: 1. Code-Source: /C:/oracle123/j2ee/home/shared-lib/other_sets/1.0/dom4j-1.6.1.jar (from in /C:/oracle123/j2ee/home/config/server.xml) This code-source is available in loader other_sets:1.0. with bset regards,
ishaan -
JPA and JSF - Problem persisting object
Hi all.
I'm having some trouble with JPA, persisting an object to a MySQL table.
Let's say I have a simple bean, Message:
package my.package
import java.io.Serializable;
import javax.persistence.Id;
import javax.persistence.Entity;
import javax.persistence.Column;
import javax.persistence.Table;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
@Entity
@Table(name="messages")
public class Message implements Serializable {
@Id
@GeneratedValue(strategy=GenerationType.AUTO)
private int id;
@Column(name="message_text")
private String message;
@Column(name="message_author")
private String author;
public String getMessage() {
return this.message;
public void setMessage(String message) {
this.message = message;
public String getAuthor() {
return this.author;
public void setAuthor(String author) {
this.author = author;
}And a controller for this Message bean:
package my.package;
import javax.annotation.Resource;
import javax.persistence.Query;
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.PersistenceUnit;
import javax.transaction.UserTransaction;
public class MessageController {
@PersistenceUnit(unitName="em1")
private EntityManagerFactory emf;
@Resource
private UserTransaction utx;
private Message message;
public Message getMessage() {
return this.message;
public void setMessage(Message message) {
this.message = message;
public String save() {
EntityManager em = null;
String returnValue = "";
try {
em = this.emf.createEntityManager();
utx.begin();
em.persist(this.message);
utx.commit();
returnValue = "success";
} catch(Exception e) {
e.printStackTrace();
returnValue = "failure";
return returnValue;
}Relevant code from the faces-config.xml:
<managed-bean>
<managed-bean-name>MessageController</managed-bean-name>
<managed-bean-class>my.package.MessageController</managed-bean-class>
<managed-bean-scope>request</managed-bean-scope>
<managed-property>
<property-name>message</property-name>
<property-class>my.package.Message</property-class>
<value>#{Message}</value>
</managed-property>
</managed-bean>
<managed-bean>
<managed-bean-name>Message</managed-bean-name>
<managed-bean-class>my.package.Message</managed-bean-class>
<managed-bean-scope>request</managed-bean-scope>
</managed-bean>This is my simple persistence.xml:
<?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 ="em1">
<jta-data-source>jdbc/__glfish</jta-data-source>
</persistence-unit>
</persistence>The __glfish resource is all set up via Glassfish to point to my MySQL server, via a MySQLPool.
Can anyone see what I'm doing wrong? The Message doesn't get added to the table in my database, and I get a NullPointerException in the method MessageController.save() on the property MessageController.message - which I have specified in the faces-config.xml. Shouldn't that be enough? What have I missed?Ok, I have (re-)located the problem. It's not my Message property which gets a NullPointerException - it seems like the problem is with my EntityManagerFactory instance. The PersistenceUnit don't get assigned, even though I declare it in my persistence.xml file.
Maybe it is something wrong with my file structure?
The .war file have this structure:
- WEB-INF
- classes
- my
- package
Message.class
MessageController.class
- lib
[external jars goes here]
- META-INF
persistence.xml
faces-config.xml
web.xml
[*.jsp/*.xhtml goes here]Can anyone see what's wrong? -
Call stored function / stored procedure from JAVA/JPA and pass array
I fail calling a plsql function from java with jpa - it works perfect without the array but its not working with the array:
PLSQL Function:
function getHtml(pWhere VARCHAR2 DEFAULT NULL,
pColSort HTP.STRINGARRAY) return clob is
begin
errorhndl.Log(pMessage => 'called');
htp.prn('das ist der test
for i in 1 .. pColSort.count loop
htp.p('
pColSort['||i||']: '||pColSort(i));
end loop;
htp.prn('
<table> <tr> <td> max1.0 </td> <td> max2.0 </td> </tr>');
htp.prn('<tr> <td> max1.1 </td> <td> max2.1 </td> </tr> </table>');
htp.prn('test ende');
return htp.gHtpPClob;
exception
when others then
null;
end getHtml;
PLSQL TYPE: (in HTP package - self created - but could be anywhere else too)
type STRINGARRAY is table of varchar2(256) index by binary_integer;
JAVA DOA:
public class ShowReportDOAImpl implements ShowReportDOA {
private JdbcTemplate jdbcTemplate;
private SimpleJdbcCall procShowReport;
public void setJdbcTemplate(JdbcTemplate jdbcTemplate) {
this.jdbcTemplate = jdbcTemplate;
procShowReport = new SimpleJdbcCall(this.jdbcTemplate)
.withCatalogName("Show_Report")
.withFunctionName("getHtml")
.withoutProcedureColumnMetaDataAccess()
.declareParameters(
new SqlParameter("pWhere", Types.VARCHAR),
new SqlParameter("pColSort", Types.ARRAY, "HTP.STRINGARRAY"),
new SqlOutParameter("RETURN", Types.CLOB)
public String readReport(Long id, ParameterHelper ph) {
String[] sortCol = {"max", "michi", "stefan"};
String pWhere = "fritz";
MapSqlParameterSource parms = new MapSqlParameterSource();
parms.addValue("pWhere", pWhere);
parms.addValue("pColSort", sortCol, Types.ARRAY, "HTP.STRINGARRAY");
parms.addValue("pColSort", Arrays.asList(sortCol), Types.ARRAY, "HTP.STRINGARRAY");
Clob clob = procShowReport.executeFunction(Clob.class, parms);
String clobString = "";
try {
System.out.println("length: "+new Long(clob.length()).intValue());
clobString = clob.getSubString(1, new Long(clob.length()).intValue());
} catch (SQLException e) {
e.printStackTrace();
return clobString;
EXCEPTION IS:
org.springframework.jdbc.UncategorizedSQLException: CallableStatementCallback; uncategorized SQLException for SQL [{? = call SHOW_REPORT.GETHTML(?, ?)}]; SQL state [null]; error code [17059]; Konvertierung zu interner Darstellung nicht erfolgreich: [max, michi, stefan]; nested exception is java.sql.SQLException: Konvertierung zu interner Darstellung nicht erfolgreich: [max, michi, stefan]
org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:83)
org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:80)
org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:80)
org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:969)
org.springframework.jdbc.core.JdbcTemplate.call(JdbcTemplate.java:1003)
org.springframework.jdbc.core.simple.AbstractJdbcCall.executeCallInternal(AbstractJdbcCall.java:391)
org.springframework.jdbc.core.simple.AbstractJdbcCall.doExecute(AbstractJdbcCall.java:354)
org.springframework.jdbc.core.simple.SimpleJdbcCall.executeFunction(SimpleJdbcCall.java:154)
at.ontec.cat.config.doa.ShowReportDOAImpl.readReport(ShowReportDOAImpl.java:47)
at.ontec.cat.http.ShowReport.doGet(ShowReport.java:80)
javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
org.springframework.orm.jpa.support.OpenEntityManagerInViewFilter.doFilterInternal(OpenEntityManagerInViewFilter.java:113)
org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
root cause
java.sql.SQLException: Konvertierung zu interner Darstellung nicht erfolgreich: [max, michi, stefan]
oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:124)
oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:161)
oracle.jdbc.driver.DatabaseError.check_error(DatabaseError.java:860)
oracle.sql.ARRAY.toARRAY(ARRAY.java:209)
oracle.jdbc.driver.OraclePreparedStatement.setObjectCritical(OraclePreparedStatement.java:7767)
oracle.jdbc.driver.OraclePreparedStatement.setObjectInternal(OraclePreparedStatement.java:7448)
oracle.jdbc.driver.OraclePreparedStatement.setObjectInternal(OraclePreparedStatement.java:7836)
oracle.jdbc.driver.OracleCallableStatement.setObject(OracleCallableStatement.java:4586)
org.apache.commons.dbcp.DelegatingPreparedStatement.setObject(DelegatingPreparedStatement.java:166)
org.apache.commons.dbcp.DelegatingPreparedStatement.setObject(DelegatingPreparedStatement.java:166)
org.springframework.jdbc.core.StatementCreatorUtils.setValue(StatementCreatorUtils.java:356)
org.springframework.jdbc.core.StatementCreatorUtils.setParameterValueInternal(StatementCreatorUtils.java:216)
org.springframework.jdbc.core.StatementCreatorUtils.setParameterValue(StatementCreatorUtils.java:127)
org.springframework.jdbc.core.CallableStatementCreatorFactory$CallableStatementCreatorImpl.createCallableStatement(CallableStatementCreatorFactory.java:212)
org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:947)
org.springframework.jdbc.core.JdbcTemplate.call(JdbcTemplate.java:1003)
org.springframework.jdbc.core.simple.AbstractJdbcCall.executeCallInternal(AbstractJdbcCall.java:391)
org.springframework.jdbc.core.simple.AbstractJdbcCall.doExecute(AbstractJdbcCall.java:354)
org.springframework.jdbc.core.simple.SimpleJdbcCall.executeFunction(SimpleJdbcCall.java:154)
at.ontec.cat.config.doa.ShowReportDOAImpl.readReport(ShowReportDOAImpl.java:47)
at.ontec.cat.http.ShowReport.doGet(ShowReport.java:80)
javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
org.springframework.orm.jpa.support.OpenEntityManagerInViewFilter.doFilterInternal(OpenEntityManagerInViewFilter.java:113)
org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
Please help!!
Please help!!user8374822 wrote:
PLSQL Function:
function getHtml(pWhere VARCHAR2 DEFAULT NULL,
pColSort HTP.STRINGARRAY) return clob is
begin
end getHtml;
PLSQL TYPE: (in HTP package - self created - but could be anywhere else too)
type STRINGARRAY is table of varchar2(256) index by binary_integer;
JAVA DOA:
new SqlParameter("pColSort", Types.ARRAY, "HTP.STRINGARRAY"),I don't know much (??) java and can't understand your error messages as they are not in english.
But I have a feeling that the error is because either
a) "Types.ARRAY" in Java world probably does not map to an index-by table in oracle or
b) the array must be created as a SQL TYPE and not as a package variable or
c) both of the above
You may want to try following approaches
1) Change the array type declaration to nested table i.e. use "type STRINGARRAY is table of varchar2(256)"
2) If the above does not work, then create a sql type (using CREATE TYPE statement) to create STRINGARRAY as a SQL type of varchar2(256)
Hope this helps.
Maybe you are looking for
-
Generic Data Source issue in CRM.
Hi Guru's, Generic Data Source with Table gave an issue "invalid Extracture structure template XXXXX of Data source XXXXX" Generic Data source with Function Module gave an issue "Units field VOLUM_U for field VOLUME of DataSource ZTEST_XYZ is hidden
-
Hi, We have to make an Asset report but we are unable to get some fields: Acquisition Cost: Original Asset Addition in this year Retirement in this year Transfer in this year Current Asset cost Dep. Cost Original Asset Addition in this year Retiremen
-
We're designing a booklet, and the client needs to see the spreads, not just one page at a time. I can export a .pdf... but I'd like to just share the .indd file. [Moved from the generic Cloud forum to the specific Program forum... Mod]
-
Facebook 2.0 App Parts Working
Dear BB Community I have been having this problem with my facebook app. I have rebooted, ininstalled and reinstalled, I have backed-up both new and old data and restored, but am still having problems uploading and downloading shared info (data). It d
-
Still Can't Uncheck All Keywords
I use the Aperture Filter every day, all the time, to locate photos. But with more than 100,000 photos in my library, I have hundreds of keywords. Which means that when I'm finished with a keyword filter, it's a royal pain to scroll through the long,