You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@openjpa.apache.org by chintan4181 <ch...@gmail.com> on 2011/09/27 18:25:08 UTC

How to Enable Buildtime entity enhancement in RSA?

Hi,

I am using RSA 8 with Websphere 7 and long back i have enabled buildtime JPA
entity ehancement in my JPA project to generate _.Java class automatically.
so whenever I add new entity class say A.java, it generates A_.java
autotmatically.

Some how i forgot how did i enable that? does anybody know configuration
settings in RSA?

Thanks
Unmarshall

--
View this message in context: http://openjpa.208410.n2.nabble.com/How-to-Enable-Buildtime-entity-enhancement-in-RSA-tp6836583p6836583.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.

Re: How to Enable Buildtime entity enhancement in RSA?

Posted by chintan4181 <ch...@gmail.com>.
Sure Kevin. Let me create new post with all details.

Thanks
unmarshall

--
View this message in context: http://openjpa.208410.n2.nabble.com/How-to-Enable-Buildtime-entity-enhancement-in-RSA-tp6836583p6841828.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.

Re: How to Enable Buildtime entity enhancement in RSA?

Posted by Kevin Sutter <kw...@gmail.com>.
Hi,
Your posts are going all over the map...  It looks like you are attempting
to track several different issues and the details are getting muddled...

Since you are using WebSphere, have you considered using the PMR process to
track this problem?  You might get a more dedicated response...

If you want to continue down this forum path, then I would suggest creating
and posting a reproducible scenario.  Right now, I think I am as confused as
you are...  :-)

Thanks,
Kevin

On Wed, Sep 28, 2011 at 3:21 PM, chintan4181 <ch...@gmail.com> wrote:

> Sorry. It was my mistake. I was trying different scenairos. I forgot to
> remove @Embeddable annotation.
>
> If i use embeddable, I am getting below exception
> org.apache.openjpa.persistence.InvalidStateException: Cannot instantiate
> virtual mapping "com.company.vo.BranchVO".
>
> I am running application on WAS 7 and using application managed entity
> manager because we have requirement to get the entity manager based on
> business department.
>
> --
> View this message in context:
> http://openjpa.208410.n2.nabble.com/How-to-Enable-Buildtime-entity-enhancement-in-RSA-tp6836583p6841736.html
> Sent from the OpenJPA Users mailing list archive at Nabble.com.
>

Re: How to Enable Buildtime entity enhancement in RSA?

Posted by chintan4181 <ch...@gmail.com>.
Sorry. It was my mistake. I was trying different scenairos. I forgot to
remove @Embeddable annotation. 

If i use embeddable, I am getting below exception 
org.apache.openjpa.persistence.InvalidStateException: Cannot instantiate
virtual mapping "com.company.vo.BranchVO".

I am running application on WAS 7 and using application managed entity
manager because we have requirement to get the entity manager based on
business department.

--
View this message in context: http://openjpa.208410.n2.nabble.com/How-to-Enable-Buildtime-entity-enhancement-in-RSA-tp6836583p6841736.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.

Re: How to Enable Buildtime entity enhancement in RSA?

Posted by Kevin Sutter <kw...@gmail.com>.
Hi,
BranchVO is an Embeddable.  The enhancement process should process @Entity,
@MappedSuperClass, and @Embeddable POJOs.

You mentioned earlier that you were using WebSphere.  But, the code snippet
below shows you manually creating the EMF and EM.  So, I would guess that
for this test case, you are not running within WebSphere.  And, if that's
the case, then how are you enhancing your POJOs?  A simple enhancement
technique for testcases running outside of an app server is to use the
-javaagent:<location of OpenJPA library> parameter.

>From your description, it does look to be a simple case of non-enhancement.
Now we just need to figure out why your POJOs are not getting enhanced, even
though you think they should be.

Thanks,
Kevin


On Wed, Sep 28, 2011 at 12:16 PM, chintan4181 <ch...@gmail.com> wrote:

> Hi kevin,
> Attached POJO:--
> http://openjpa.208410.n2.nabble.com/file/n6841060/BranchVO.java
> BranchVO.java
>
> Code snippet to retrieve values
>
> //native sql query
> String njSql = "SELECT b.branch_id, b.branch_cust_id,
> ba.branch_address_street1 from branch as b," +
>                                "branch_address as ba where b.branch_id =
> ?";
>
> EntityManager em = emf.createEntityManager("pu1");
> //fails at this point while retrieving entities defined in pesistent.xml
> Set&lt;EntityType&lt;?&gt;> em1Entitites = em.getMetamodel().getEntities();
>
>                for (EntityType type : em1Entitites) {
>                        Class javaType = type.getJavaType();
>                        if
> (javaType.getName().equals(BranchVO.class.getName())) {
>                                break;
>                        }
>                }
>
> Gives error saying, BranchVO is not enhanced. I understood because it's not
> having @Entity. But i want to populate objet using native query without
> defining native query in an Entity .
>
> Let me know if you need more information
>
>
>
>
> --
> View this message in context:
> http://openjpa.208410.n2.nabble.com/How-to-Enable-Buildtime-entity-enhancement-in-RSA-tp6836583p6841060.html
> Sent from the OpenJPA Users mailing list archive at Nabble.com.
>

Re: How to Enable Buildtime entity enhancement in RSA?

Posted by chintan4181 <ch...@gmail.com>.
Hi kevin,
Attached POJO:--
http://openjpa.208410.n2.nabble.com/file/n6841060/BranchVO.java
BranchVO.java 

Code snippet to retrieve values 

//native sql query
String njSql = "SELECT b.branch_id, b.branch_cust_id,
ba.branch_address_street1 from branch as b," +
				"branch_address as ba where b.branch_id = ?";

EntityManager em = emf.createEntityManager("pu1");
//fails at this point while retrieving entities defined in pesistent.xml
Set&lt;EntityType&lt;?&gt;> em1Entitites = em.getMetamodel().getEntities();

		for (EntityType type : em1Entitites) {
			Class javaType = type.getJavaType();
			if (javaType.getName().equals(BranchVO.class.getName())) {
				break;
			}
		}

Gives error saying, BranchVO is not enhanced. I understood because it's not
having @Entity. But i want to populate objet using native query without
defining native query in an Entity .

Let me know if you need more information




--
View this message in context: http://openjpa.208410.n2.nabble.com/How-to-Enable-Buildtime-entity-enhancement-in-RSA-tp6836583p6841060.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.

Re: How to Enable Buildtime entity enhancement in RSA?

Posted by Kevin Sutter <kw...@gmail.com>.
Hi,
You have been referencing "code", but I haven't seen any code attachments or
code snippets to look at...

A good reference for OpenJPA's enhancement processing can be found on our
wiki:
http://openjpa.apache.org/entity-enhancement.html

You are correct.  There are hooks in the WebSphere code to tie into the
classloading mechanism and automatically enhance the Entity classes that are
getting loaded.  This is the probably the easiest mechanism to ensure that
your classes are getting enhanced.

I'm not clear on what type of custom object you are trying to process.  JPA
requires at least the @Entity annotation (or orm.xml equivalent) to indicate
a POJO to be an Entity or not.  This would also apply to our enhancement
processing.  OpenJPA doesn't want to try to enhance all classes, especially
in the case of automatic dynamic enhancement like with the WebSphere hook.

Maybe we need more background on what's really being attempted (with code
snippets or examples).

Thanks,
Kevin

On Tue, Sep 27, 2011 at 5:13 PM, chintan4181 <ch...@gmail.com> wrote:

> Hi Pinaki,
>
> I have created java bean (custom object) and defined in persistent xml. I
> have created native query and mapped attibutes to java bean. I was able to
> get the object properly.  I have canonical meta-model is on.
>
> If i use below code, it give me error saying, class is not enahnced. I
> understood because it's not annotated with @entity. and by default WAS 7.0
> is enahcing all entity class.
>
> Is there way i can enhance custom bean ? or what should be the suggested
> way
> to handle this?
>
> Thanks
> unmarshall
>
>
>
> --
> View this message in context:
> http://openjpa.208410.n2.nabble.com/How-to-Enable-Buildtime-entity-enhancement-in-RSA-tp6836583p6838031.html
> Sent from the OpenJPA Users mailing list archive at Nabble.com.
>

Re: How to Enable Buildtime entity enhancement in RSA?

Posted by chintan4181 <ch...@gmail.com>.
Hi Pinaki,

I have created java bean (custom object) and defined in persistent xml. I
have created native query and mapped attibutes to java bean. I was able to
get the object properly.  I have canonical meta-model is on. 

If i use below code, it give me error saying, class is not enahnced. I
understood because it's not annotated with @entity. and by default WAS 7.0
is enahcing all entity class.

Is there way i can enhance custom bean ? or what should be the suggested way
to handle this?

Thanks
unmarshall



--
View this message in context: http://openjpa.208410.n2.nabble.com/How-to-Enable-Buildtime-entity-enhancement-in-RSA-tp6836583p6838031.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.

Re: How to Enable Buildtime entity enhancement in RSA?

Posted by Pinaki Poddar <pp...@apache.org>.
> Does meta model generation have impact on performance? 
no

-----
Pinaki Poddar
Chair, Apache OpenJPA Project
--
View this message in context: http://openjpa.208410.n2.nabble.com/How-to-Enable-Buildtime-entity-enhancement-in-RSA-tp6836583p6837991.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.

Re: How to Enable Buildtime entity enhancement in RSA?

Posted by chintan4181 <ch...@gmail.com>.
Hi I am getting below exception.

 org.apache.openjpa.util.MetaDataException: No metadata was found for type
"class com.company.vo.TestEnity". The class is not enhanced.

I am running my application on WAS 7.0. How do i enhance TestEntity at
runtime? what entry i should put as JVM arguments?



--
View this message in context: http://openjpa.208410.n2.nabble.com/How-to-Enable-Buildtime-entity-enhancement-in-RSA-tp6836583p6837923.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.

Re: How to Enable Buildtime entity enhancement in RSA?

Posted by chintan4181 <ch...@gmail.com>.
Does meta model generation have impact on performance? 

--
View this message in context: http://openjpa.208410.n2.nabble.com/How-to-Enable-Buildtime-entity-enhancement-in-RSA-tp6836583p6837636.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.

Re: How to Enable Buildtime entity enhancement in RSA?

Posted by Kevin Sutter <kw...@gmail.com>.
Hi,
I think you are referring to the metamodel generation (*_.java) instead of
performing the byte code enhancing.

The metamodel generation just requires an additional parameter on your javac
invocation:

$ javac -classpath path/to/openjpa-all.jar -Aopenjpa.metamodel=true
mypackage/MyEntity.java

More information can be found here:
http://openjpa.apache.org/builds/latest/docs/manual/manual.html#d0e11235

HTH,
Kevin

On Tue, Sep 27, 2011 at 11:25 AM, chintan4181 <ch...@gmail.com> wrote:

> Hi,
>
> I am using RSA 8 with Websphere 7 and long back i have enabled buildtime
> JPA
> entity ehancement in my JPA project to generate _.Java class automatically.
> so whenever I add new entity class say A.java, it generates A_.java
> autotmatically.
>
> Some how i forgot how did i enable that? does anybody know configuration
> settings in RSA?
>
> Thanks
> Unmarshall
>
> --
> View this message in context:
> http://openjpa.208410.n2.nabble.com/How-to-Enable-Buildtime-entity-enhancement-in-RSA-tp6836583p6836583.html
> Sent from the OpenJPA Users mailing list archive at Nabble.com.
>