You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@openjpa.apache.org by Don Brady <db...@pobox.com> on 2007/01/15 19:37:37 UTC

Schema and Table Name sometimes being ignored when supplied onl in orm.xml

I have entities like this which intentionally omit the schema and
table names:

@Entity
// @Table(name = "V_MBK_KEY") specified in orm.xml
public class FeMbkKey implements Serializable {
........

and in orm.xml I add the name and schema:

         ......
	<persistence-unit-metadata>
	 <persistence-unit-defaults>
	   <schema>CLMR</schema>
          </persistence-unit-defaults>
	</persistence-unit-metadata>
	<package>com.ncfbins.services.mship.entity.entities</package>
	<schema>CLMR</schema>
	
	<entity class="FeMbkKey">
		<table name="V_MBK_KEY" schema="CLMR" />
	</entity>

          ......


  This works fine a lot of the time, resulting in correct queries like

SELECT MAX(f.mbkMemberIdNbr) FROM CLMR.V_MBK_KEY f .....

that work fine.

However, sometimes it gets into a permanent manner of behavior where it
omits the table and schema additions that are in orm.xml; all queries
fail in the database because schema and table never got inserted before
the query is issued.

The final query sent to the database in such cases is omitting the real
schema and table name from orm.xml:

SELECT MAX(f.mbkMemberIdNbr) FROM FeMbkKey f

Of course these fail because there is no FeMbkKey table in the database,
just a CLMR.V_MBK_KEY table.

The strange thing is that nothing helps now to get it to go back to
honoring orm.xml.  Yet, I have made essentially no changes from when it
worked to when it stopped working.

I have stepped through the openjpa source code and it is accessing and
parsing orm.xml successfully.  Perhaps someone can tell me where would
be a couple of places in the source code to set breakpoints to see why
it is not translating the entity name into the Query.  I have tried
using fully-package-qualified class names in orm.xml and that does not
help.  I have traced through PersistenceMetaDataFactory and other
classes and cannot see where it goes wrong.

This is all on 0.9.6 final under WebSphere.  It occurs on straight
openjpa 0.9.6 and also on IBM's packaged alpha update, and on multiple
fixpack levels of WebSphere.  I think I tried 0.9.7 too.

  For now, I will have to go back to putting the class and table in the
entities but eventually I want to be able to not bind those right into
the entities as we have multiple environments to run in...

  Thanks!

  Don





RE: Schema and Table Name sometimes being ignored when supplied onl in orm.xml

Posted by Patrick Linskey <pl...@bea.com>.
What do you get when you set the MetaData log channel to TRACE?

-Patrick

-- 
Patrick Linskey
BEA Systems, Inc. 

_______________________________________________________________________
Notice:  This email message, together with any attachments, may contain
information  of  BEA Systems,  Inc.,  its subsidiaries  and  affiliated
entities,  that may be confidential,  proprietary,  copyrighted  and/or
legally privileged, and is intended solely for the use of the individual
or entity named in this message. If you are not the intended recipient,
and have received this message in error, please immediately return this
by email and then delete it. 

> -----Original Message-----
> From: Don Brady [mailto:dbrady@pobox.com] 
> Sent: Monday, January 15, 2007 10:38 AM
> To: open-jpa-dev@incubator.apache.org
> Subject: Schema and Table Name sometimes being ignored when 
> supplied onl in orm.xml
> 
> I have entities like this which intentionally omit the schema and
> table names:
> 
> @Entity
> // @Table(name = "V_MBK_KEY") specified in orm.xml
> public class FeMbkKey implements Serializable {
> ........
> 
> and in orm.xml I add the name and schema:
> 
>          ......
> 	<persistence-unit-metadata>
> 	 <persistence-unit-defaults>
> 	   <schema>CLMR</schema>
>           </persistence-unit-defaults>
> 	</persistence-unit-metadata>
> 	<package>com.ncfbins.services.mship.entity.entities</package>
> 	<schema>CLMR</schema>
> 	
> 	<entity class="FeMbkKey">
> 		<table name="V_MBK_KEY" schema="CLMR" />
> 	</entity>
> 
>           ......
> 
> 
>   This works fine a lot of the time, resulting in correct queries like
> 
> SELECT MAX(f.mbkMemberIdNbr) FROM CLMR.V_MBK_KEY f .....
> 
> that work fine.
> 
> However, sometimes it gets into a permanent manner of 
> behavior where it
> omits the table and schema additions that are in orm.xml; all queries
> fail in the database because schema and table never got 
> inserted before
> the query is issued.
> 
> The final query sent to the database in such cases is 
> omitting the real
> schema and table name from orm.xml:
> 
> SELECT MAX(f.mbkMemberIdNbr) FROM FeMbkKey f
> 
> Of course these fail because there is no FeMbkKey table in 
> the database,
> just a CLMR.V_MBK_KEY table.
> 
> The strange thing is that nothing helps now to get it to go back to
> honoring orm.xml.  Yet, I have made essentially no changes 
> from when it
> worked to when it stopped working.
> 
> I have stepped through the openjpa source code and it is accessing and
> parsing orm.xml successfully.  Perhaps someone can tell me where would
> be a couple of places in the source code to set breakpoints to see why
> it is not translating the entity name into the Query.  I have tried
> using fully-package-qualified class names in orm.xml and that does not
> help.  I have traced through PersistenceMetaDataFactory and other
> classes and cannot see where it goes wrong.
> 
> This is all on 0.9.6 final under WebSphere.  It occurs on straight
> openjpa 0.9.6 and also on IBM's packaged alpha update, and on multiple
> fixpack levels of WebSphere.  I think I tried 0.9.7 too.
> 
>   For now, I will have to go back to putting the class and 
> table in the
> entities but eventually I want to be able to not bind those right into
> the entities as we have multiple environments to run in...
> 
>   Thanks!
> 
>   Don
> 
> 
> 
> 
>