Hi,
We are struck with 2 problems:
1. We have written orm.xml file for our application and we are getting the
following exception. We are also attaching our orm.xml and persistance.xml
files for your reference.
[openjpac] 6281 host TRACE [main] openjpa.MetaData -
parsePersistentTypeNames() found [com.vormetric.server.dao.user.UserDTO,
com.vormetric.server.dao.user.RoleDTO].
[openjpac] 6281 host TRACE [main] openjpa.MetaData - Found 2 classes with
metadata in 46 milliseconds.
[openjpac] 6344 host TRACE [main] openjpa.MetaData - Parsing class
"com.vormetric.server.dao.user.RoleDTO".
[openjpac] 6344 host TRACE [main] openjpa.Enhance - Enhancing type "class
com.vormetric.server.dao.user.RoleDTO".
[openjpac] 6344 host WARN [main] openjpa.Enhance - Type "class
com.vormetric.server.dao.user.RoleDTO" has no metadata; enhancing as
persistence aware. If you intended for "class
com.vormetric.server.dao.user.RoleDTO" to be persistence-capable, then this
means that OpenJPA could not find any metadata for "class
com.vormetric.server.dao.user.RoleDTO". This can happen if the directory
containing your metadata is not in your CLASSPATH, or if your metadata files
are not named properly. See the documentation on metadata placement for more
information.
[openjpac] 6344 host TRACE [main] openjpa.Tool - The class does not have
metadata - enhanced as persistence-aware.
[openjpac] 6391 host TRACE [main] openjpa.Tool - Enhancer running on type
"class com.vormetric.server.dao.user.UserDTO".
[openjpac] 6422 host TRACE [main] openjpa.MetaData - Loading metadata for
"class com.vormetric.server.dao.user.UserDTO" under mode "[META][QUERY]".
[openjpac] 6422 host TRACE [main] openjpa.MetaData - Parsing class
"com.vormetric.server.dao.user.UserDTO".
[openjpac] 6422 host TRACE [main] openjpa.Enhance - Enhancing type "class
com.vormetric.server.dao.user.UserDTO".
[openjpac] 6422 host WARN [main] openjpa.Enhance - Type "class
com.vormetric.server.dao.user.UserDTO" has no metadata; enhancing as
persistence aware. If you intended for "class
com.vormetric.server.dao.user.UserDTO" to be persistence-capable, then this
means that OpenJPA could not find any metadata for "class
com.vormetric.server.dao.user.UserDTO". This can happen if the directory
containing your metadata is not in your CLASSPATH, or if your metadata files
are not named properly. See the documentation on metadata placement for more
information.
[openjpac] 6422 host TRACE [main] openjpa.Tool - The class does not have
metadata - enhanced as persistence-aware.
[openjpac] 6453 host TRACE [main] openjpa.MetaData - Clearing metadata
repository "[EMAIL PROTECTED]".
2. To make an entity readonly in an application(described below).
Please help us in resolving these two problems as we have struck with these
two problems. We are not able to findout where exactly is the mistake in our
configurations.
Thanks,
Praveen Kumar.
----- Original Message -----
From: Praveen G
To: [email protected] ; Patrick Linskey
Cc: Budigam Srinivas Rao ; Murali Adiraju ; Deven Kalra ; Lane Bauldry
Sent: Wednesday, May 23, 2007 8:41 PM
Subject: Re: Problem with Entity Cache
Hi,
Please help us in resolving the following problem.
Thanks,
Praveen Kumar.
----- Original Message -----
From: Praveen G
To: [email protected] ; Patrick Linskey
Cc: Budigam Srinivas Rao ; Murali Adiraju
Sent: Tuesday, May 22, 2007 8:27 PM
Subject: Problem with Entity Cache
Hello Patrick Linskey,
We are facing the following problem in our project.
<0.9.7-incubating fatal user error>
org.apache.openjpa.persistence.InvalidStateException: Encountered unmanaged
object "[EMAIL PROTECTED]" in persistent field
"com.vormetric.server.dao.user.UserDTO.roles<element:class
com.vormetric.server.dao.user.RoleDTO>" of managed object "[EMAIL PROTECTED]"
during flush. However, this field does not allow cascade persist. You cannot
flush unmanaged objects.
FailedObject: [EMAIL PROTECTED]
at
org.apache.openjpa.kernel.SingleFieldManager.preFlushPC(SingleFieldManager.java:750)
at
org.apache.openjpa.kernel.SingleFieldManager.preFlushPCs(SingleFieldManager.java:732)
at
org.apache.openjpa.kernel.SingleFieldManager.preFlush(SingleFieldManager.java:634)
at
org.apache.openjpa.kernel.SingleFieldManager.preFlush(SingleFieldManager.java:559)
at
org.apache.openjpa.kernel.SingleFieldManager.preFlush(SingleFieldManager.java:475)
at
org.apache.openjpa.kernel.StateManagerImpl.preFlush(StateManagerImpl.java:2678)
at org.apache.openjpa.kernel.PNewState.beforeFlush(PNewState.java:39)
at
org.apache.openjpa.kernel.StateManagerImpl.beforeFlush(StateManagerImpl.java:854)
at org.apache.openjpa.kernel.BrokerImpl.flush(BrokerImpl.java:1903)
at org.apache.openjpa.kernel.BrokerImpl.flushSafe(BrokerImpl.java:1863)
at org.apache.openjpa.kernel.BrokerImpl.flush(BrokerImpl.java:1634)
at
org.apache.openjpa.kernel.StateManagerImpl.assignObjectId(StateManagerImpl.java:478)
at
org.apache.openjpa.kernel.StateManagerImpl.assignField(StateManagerImpl.java:558)
at
org.apache.openjpa.kernel.StateManagerImpl.beforeAccessField(StateManagerImpl.java:1365)
at
org.apache.openjpa.kernel.StateManagerImpl.accessingField(StateManagerImpl.java:1348)
at com.vormetric.server.dao.user.UserDTO.pcGetid(UserDTO.java)
at com.vormetric.server.dao.user.UserDTO.getId(UserDTO.java:93)
at
com.vormetric.server.dao.user.hibernate.UserDAOImpl.create(UserDAOImpl.java:89)
at com.vormetric.server.sdk.user.UserManager.addUser(UserManager.java:52)
at
com.vormetric.server.mgmt.console.user.UserAddAction.execute(UserAddAction.java:67)
We are having 2 entity classes UserDTO and RoleDTO files. We want the
RoleDTO entity to be readonly.
So Please help us to make an entity readonly in an application.
The following is the tag in our existing hibernate mapping file. We are
replacing the hibernate code with OpenJPA code
<hibernate-mapping>
<class name="com.vormetric.server.dao.user.RoleDTO" table="CGSS_ROLE">
<cache usage="read-only"/>
So please help us as soon as possible, to make an entity readonly.
Thanks,
Praveen Kumar.
<?xml version="1.0" encoding="UTF-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
<persistence xmlns="http://java.sun.com/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
version="1.0">
<!--
We need to enumerate each persistent class first in the persistence.xml
See: http://issues.apache.org/jira/browse/OPENJPA-78
-->
<!--
A persistence unit is a set of listed persistent entities as well
the configuration of an EntityManagerFactory. We configure each
example in a separate persistence-unit.
-->
<persistence-unit name="host" transaction-type="RESOURCE_LOCAL">
<provider>
org.apache.openjpa.persistence.PersistenceProviderImpl
</provider>
<mapping-file>orm.xml</mapping-file>
<class>com.vormetric.server.dao.user.RoleDTO</class>
<class>com.vormetric.server.dao.user.UserDTO</class>
<properties>
<property name="openjpa.ConnectionURL" value="jdbc:db2:CGSSDB"/>
<property name="openjpa.ConnectionDriverName" value="COM.ibm.db2.jdbc.app.DB2Driver"/>
<property name="openjpa.ConnectionUserName" value="voradmin"/>
<property name="openjpa.ConnectionPassword" value="voradmin"/>
<property name="openjpa.Log" value="DefaultLevel=TRACE,SQL=TRACE" />
<property name="openjpa.RetryClassRegistration" value="true"/>
<property name="openjpa.jdbc.DBDictionary" value="db2"/>
</properties>
</persistence-unit>
</persistence>
<?xml version="1.0" encoding="UTF-8"?>
<entity-mappings xmlns="http://java.sun.com/xml/ns/persistence/orm"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence/orm http://java.sun.com/xml/ns/persistence/orm_1_0.xsd http://incubator.apache.org/openjpa/orm http://incubator.apache.org/openjpa/xml/ns/persistence/openjpa_orm_1_0.xsd"
version="1.0">
<persistence-unit-metadata>
<persistence-unit-defaults>
<schema>CGSSDB</schema>
<access>FIELD</access>
</persistence-unit-defaults>
</persistence-unit-metadata>
<package>com.vormetric.server.dao.user</package>
<entity class="RoleDTO" metadata-complete="false" access="FIELD">
<table name="CGSS_ROLE" schema="CGSSDB"/>
<attributes>
<id name="id">
<column name="ROLE_ID"/>
<generated-value strategy="IDENTITY"/>
</id>
<basic name="name">
<column name="ROLE_NAME"/>
</basic>
</attributes>
</entity>
<entity class="UserDTO" metadata-complete="false" access="FIELD">
<table name="CGSS_USER" schema="CGSSDB"/>
<attributes>
<id name="id">
<column name="USER_ID"/>
<generated-value strategy="IDENTITY"/>
</id>
<basic name="name"><column name="USER_NAME"/></basic>
<basic name="password"><column name="PASSWORD"/></basic>
<basic name="enabled"><column name="ENABLED"/></basic>
<basic name="needReset"><column name="NEED_RESET"/></basic>
<basic name="passwordResetDate"><column name="PASSWORD_RESET_DATE"/></basic>
<basic name="passwordDuration"><column name="PASSWORD_DURATION"/></basic>
<many-to-many name="roles" fetch="LAZY" target-entity="com.vormetric.server.dao.user.RoleDTO">
<join-table name="CGSS_USER_ROLE_MAPPING" schema="CGSSDB">
<join-column name="USER_ID" referenced-column-name="USER_ID"/>
<inverse-join-column name="ROLE_ID" referenced-column-name="ROLE_ID"/>
</join-table>
</many-to-many>
</attributes>
</entity>
</entity-mappings>