RE: Generation of entity classes

2007-01-01 Thread Patrick Linskey
Generally-speaking, you should be able to bootstrap new classes into
OpenJPA over time. There are some situations that will prevent this
(i.e., if exclude-unlisted-classes is set to true, and possibly some
automatic class-scanning modes).

-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: Dain Sundstrom [mailto:[EMAIL PROTECTED] 
 Sent: Sunday, December 31, 2006 9:19 PM
 To: open-jpa-dev@incubator.apache.org
 Subject: Re: Generation of entity classes
 
 Actually, never mind.  Due to the interconnectedness of persistent  
 classes (i.e., relationships), I need to generate all the classes at  
 once and add them all to the class loader at the same time.  This  
 means my elegant solution is just broken :)
 
 -dain
 
 On Dec 31, 2006, at 3:12 PM, Dain Sundstrom wrote:
 
  I working on an implementation of the EJB cmp specification which  
  uses JPA under the covers to implement the persistence.  I 
 have the  
  basics working with hand written subclasses of the abstract cmp2  
  beans.  I just wrote a code generator to replace my hand coded  
  subclasses using ASM (which rocks), and I am having problems  
  getting OpenJPA to enhance my generated class.  It appears that at  
  the moment I construct the EMF all entity classes must be 
 available  
  via the temp class loader.  If they are not, OpenJPA will not add  
  an entry into the MetaData repository.  Later when I generate my  
  class and load it, the OpenJPA transformer looks for the MetaData  
  in the repository, doesn't find it, and completely skips  
  enhancement (PCEnhancer line 322).  It is possible to have the  
  enhancer fault load the metadata and continue with enhancement?
 
  In the mean time, I'm going to hack OpenEJB to kick off generation  
  very early in deployment, but it would be much more elegant 
 to wait  
  until the EJB is deployed to generate the classes and this happens  
  after JPA is initialized.
 
  Thanks,
 
  -dain
 
 


Should UserTransaction Work?

2007-01-01 Thread Don Brady

I cannot get UserTransaction to work.

Nothing happens when I commit.

This consists of:

- Using a JTA datasource
- specifying Bean Managed Transaction rather then CMT on the enclosing 
session Bean.

- looking up a UserTransaction with:
UserTransaction userTran = (UserTransaction) initCtx
   .lookup(java:comp/UserTransaction);

then doing a begin on it, some entity lookup and changes, and a commit.

Could anyone tell me if this should work?  


This is under WebSphere 6.1.

As background, I am able to get a JTA data source to work fine if I use 
Container Managed Transactions rather than BMT.  The problem with that 
approach for me is that I am calling the session Bean as a 
web-service-enable endpoint.  If I leave committing the transaction 
entirely to JTA, the commit  is done after all of my web service code 
has exited and any errors are thrown as soap faults.   I want to be able 
to catch the error and analyze it before returning from the web 
service.  I can also do this fine with Resource Local Transactions but 
then I do not get the benefits of a JTA datasource managed by WebSphere.


So I am trying to use JTA with BMT which I believe would allow me to 
catch errors on commit.


If this is too much of  a user question for this list, please let me 
know.


Thanks!

Don











Getting all the ClassMetaDatas

2007-01-01 Thread Shay Banon

Hi,

   First, I hope that this is the correct forum for posting questions, so
sorry if it isn't.

I have an external list of classes that I would like to match against the
persistent classes that are defined/identified by OpenJPA. I would really
like to get the ClassMetaData for each one, since it has a lot of
information that I could use. This intersection happens after the
EntityManagerFactory has been created.

I have tried using:ClassMetaData[] classMetaDatas =
emf.getConfiguration().getMetaDataRepositoryInstance().getMetaDatas();

But it seems like the meta data repository and ClassMetaData information are
lazily loaded (i.e. when some operation is performed on a Class, the
relevant meta data is fetched if not found in cache). So, what I get is an
empty array (even though I can see the OpenJPA identified the classes).

I wonder how I would be able to get all the class meta data?

Something that I was thinking about is since I have the list of classes that
I would like to check if they are persistent, I could call:
getMetaData(Class cls, ClassLoader envLoader, boolean mustExist), with
Thread context class loader and false in mustExists. I am guessing that it
will load the ClassMetaData if not found. My main problem here is that
OpenJPA might be configured with a different class loader (though it
defaults to the thread context one).

Any suggestions?

p.s.

I am the author of Compass, so once I have this nailed down, we will have
Search capabilities to OpenJPA ;)

-- 
View this message in context: 
http://www.nabble.com/Getting-all-the-ClassMetaDatas-tf2905426.html#a8116958
Sent from the open-jpa-dev mailing list archive at Nabble.com.



Re: Generation of entity classes

2007-01-01 Thread Dain Sundstrom
I think it only works if you preehnahce.  The runtime enhancer will  
only modify on classes with metadata loaded, and the metadata seems  
to only be cached at startup.


-dain

On Jan 1, 2007, at 2:36 AM, Patrick Linskey wrote:


Generally-speaking, you should be able to bootstrap new classes into
OpenJPA over time. There are some situations that will prevent this
(i.e., if exclude-unlisted-classes is set to true, and possibly some
automatic class-scanning modes).

-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: Dain Sundstrom [mailto:[EMAIL PROTECTED]
Sent: Sunday, December 31, 2006 9:19 PM
To: open-jpa-dev@incubator.apache.org
Subject: Re: Generation of entity classes

Actually, never mind.  Due to the interconnectedness of persistent
classes (i.e., relationships), I need to generate all the classes at
once and add them all to the class loader at the same time.  This
means my elegant solution is just broken :)

-dain

On Dec 31, 2006, at 3:12 PM, Dain Sundstrom wrote:


I working on an implementation of the EJB cmp specification which
uses JPA under the covers to implement the persistence.  I

have the

basics working with hand written subclasses of the abstract cmp2
beans.  I just wrote a code generator to replace my hand coded
subclasses using ASM (which rocks), and I am having problems
getting OpenJPA to enhance my generated class.  It appears that at
the moment I construct the EMF all entity classes must be

available

via the temp class loader.  If they are not, OpenJPA will not add
an entry into the MetaData repository.  Later when I generate my
class and load it, the OpenJPA transformer looks for the MetaData
in the repository, doesn't find it, and completely skips
enhancement (PCEnhancer line 322).  It is possible to have the
enhancer fault load the metadata and continue with enhancement?

In the mean time, I'm going to hack OpenEJB to kick off generation
very early in deployment, but it would be much more elegant

to wait

until the EJB is deployed to generate the classes and this happens
after JPA is initialized.

Thanks,

-dain







RE: Getting all the ClassMetaDatas

2007-01-01 Thread Patrick Linskey
 -Original Message-
 From: Shay Banon [mailto:[EMAIL PROTECTED] 
 Sent: Monday, January 01, 2007 1:11 PM
 To: open-jpa-dev@incubator.apache.org
 Subject: Getting all the ClassMetaDatas
 
 ...
 
 p.s.
 
 I am the author of Compass, so once I have this nailed down, 
 we will have
 Search capabilities to OpenJPA ;)

Cool! FYI, you'll probably be interested in
org.apache.openjpa.event.TransactionListener and
org.apache.openjpa.event.LifecycleListener (and associated
superinterfaces).

-Patrick
___
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.


RE: Getting all the ClassMetaDatas

2007-01-01 Thread Patrick Linskey
Is there any reason why you need to eagerly get information about
classes to process? In general, as you've noticed, OpenJPA does allow
dynamic registration of persistent types. One possibility would be to
declare that in order to use Compass searching with OpenJPA, one must
provide a static list of classes (or tell OpenJPA to compute a static
list of classes), using one of the options that Marc pointed out
earlier. Alternately, you could potentially just register the right type
of listener with OpenJPA and do whatever initialization is necessary
lazily as new classes are encountered via the callbacks.

-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: Shay Banon [mailto:[EMAIL PROTECTED] 
 Sent: Monday, January 01, 2007 1:11 PM
 To: open-jpa-dev@incubator.apache.org
 Subject: Getting all the ClassMetaDatas
 
 
 Hi,
 
First, I hope that this is the correct forum for posting 
 questions, so
 sorry if it isn't.
 
 I have an external list of classes that I would like to match 
 against the
 persistent classes that are defined/identified by OpenJPA. I 
 would really
 like to get the ClassMetaData for each one, since it has a lot of
 information that I could use. This intersection happens after the
 EntityManagerFactory has been created.
 
 I have tried using:ClassMetaData[] classMetaDatas =
 emf.getConfiguration().getMetaDataRepositoryInstance().getMetaDatas();
 
 But it seems like the meta data repository and ClassMetaData 
 information are
 lazily loaded (i.e. when some operation is performed on a Class, the
 relevant meta data is fetched if not found in cache). So, 
 what I get is an
 empty array (even though I can see the OpenJPA identified the 
 classes).
 
 I wonder how I would be able to get all the class meta data?
 
 Something that I was thinking about is since I have the list 
 of classes that
 I would like to check if they are persistent, I could call:
 getMetaData(Class cls, ClassLoader envLoader, boolean mustExist), with
 Thread context class loader and false in mustExists. I am 
 guessing that it
 will load the ClassMetaData if not found. My main problem here is that
 OpenJPA might be configured with a different class loader (though it
 defaults to the thread context one).
 
 Any suggestions?
 
 p.s.
 
 I am the author of Compass, so once I have this nailed down, 
 we will have
 Search capabilities to OpenJPA ;)
 
 -- 
 View this message in context: 
 http://www.nabble.com/Getting-all-the-ClassMetaDatas-tf2905426
.html#a8116958
 Sent from the open-jpa-dev mailing list archive at Nabble.com.
 
 


RE: Getting all the ClassMetaDatas

2007-01-01 Thread Patrick Linskey
BTW, I should probably eludicate a bit. When working with
LifecycleEvents, you can get the instance associated with the event, and
from that you can get the corresponding StateManager and ClassMetaData:

Broker broker = (Broker) ((PersistenceCapable) event.getSource())
.pcGetGenericContext();
StateManager sm = broker.getStateManager(event.getSource());
ClassMetaData meta = sm.getMetaData();

With TransactionEvents, you can do:

Broker broker = (Broker) event.getSource();
for (Object o : event.getTransactionalObjects()) {
StateManager sm = broker.getStateManager(o);
ClassMetaData meta = sm.getMetaData();
if (!sm.isDirty())
continue;

// update indexes
}

Also, IMO, searching is something that shouldn't depend on the JPA spec
-- ideally, you should be able to implement all this without any
dependencies on the org.apache.openjpa.persistence package or
sub-packages.

-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: Patrick Linskey 
 Sent: Monday, January 01, 2007 5:51 PM
 To: open-jpa-dev@incubator.apache.org
 Subject: RE: Getting all the ClassMetaDatas
 
  -Original Message-
  From: Shay Banon [mailto:[EMAIL PROTECTED] 
  Sent: Monday, January 01, 2007 1:11 PM
  To: open-jpa-dev@incubator.apache.org
  Subject: Getting all the ClassMetaDatas
  
  ...
  
  p.s.
  
  I am the author of Compass, so once I have this nailed down, 
  we will have
  Search capabilities to OpenJPA ;)
 
 Cool! FYI, you'll probably be interested in
 org.apache.openjpa.event.TransactionListener and
 org.apache.openjpa.event.LifecycleListener (and associated
 superinterfaces).
 
 -Patrick
 __
 _
 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.