Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [eclipselink-users] RE: eclipselink-users Digest, Vol 18, Issue 47

Daoqa,
    1) If you check out the post by Andrei from Jan 8 2009, you will see that you may use both jta and non-jta datasources.

http://forums.oracle.com/forums/thread.jspa?messageID=3205242&tstart=0

    What you may be seeing is that the single setLookupType is setting STRING_LOOKUP only on the non-jta datasource if both are specified - the order may vary.
    Use Andrei's suggestion and set both of them to be safe and see if you are able to use both.

JNDIConnector writeConnector = (JNDIConnector) session.getLogin().getConnector();
writeConnector.setLookupType(JNDIConnector.STRING_LOOKUP);
JNDIConnector readConnector = (JNDIConnector) //((ServerSession)session).getReadConnectionPool().getLogin().getConnector();
readConnector.setLookupType(JNDIConnector.STRING_LOOKUP);
JNDIConnector readConnector = (JNDIConnector) ((DatabaseLogin)((ServerSession)session).getReadConnectionPool().getLogin()).getConnector();


    2) Thank you for that variant use case - I forgot about that scenario, The JBoss wiki needs to be updated to the same level as the Tomcat one - where we ran into this issue in Dec 2008 - I'll update the wiki.
    http://wiki.eclipse.org/EclipseLink/Examples/JPA/Tomcat_Web_Tutorial#Session_Customizer
// Change from COMPOSITE_NAME_LOOKUP to STRING_LOOKUP
// Note: if both jta and non-jta elements exist this will only change the first one - and may still result in the COMPOSITE_NAME_LOOKUP being set

// Make sure only jta-data-source is in persistence.xml with no non-jta-data-source property set
connector.setLookupType(JNDIConnector.STRING_LOOKUP);   


    thank you
    /michael

Yang, Daoqi (D.) wrote:
Michael:

I have made the JTA datasource work. As Kevin said, without doing
anything extra, EclipseLink works with Jboss, if JTA datasource is used
in persistence.xml.
The reason it did not work for me at the beginning is because I had both
non jta datasource and jta datasource in my persistence.xml, which made
neither work.
After deleting my non-jta persistence unit, the jta persistence unit
worked.

The question remains for me is that how do I make non-jta persistence
unit work with a non-jta-datasource.  If I use the JavaSE way of
configuring
the database such as
          <property name="eclipselink.jdbc.url" value=""/>
          <property name="eclipselink.jdbc.user" value=""/>
          <property name="eclipselink.jdbc.password" value=""/>
         <property name="eclipselink.jdbc.driver" value=""/>
Then it works. I will try the SessionCustomizer when I have time,
following your suggestions.

Regards,
Daoqi  Yang
Application Technology Architect
Ford Java Center of Excellence, E1F001 iTek
dyang11@xxxxxxxx, 313-206-3960

-----Original Message-----
From: eclipselink-users-bounces@xxxxxxxxxxx
[mailto:eclipselink-users-bounces@xxxxxxxxxxx] On Behalf Of
eclipselink-users-request@xxxxxxxxxxx
Sent: Wednesday, February 25, 2009 12:00 PM
To: eclipselink-users@xxxxxxxxxxx
Subject: eclipselink-users Digest, Vol 18, Issue 47

Send eclipselink-users mailing list submissions to
	eclipselink-users@xxxxxxxxxxx

To subscribe or unsubscribe via the World Wide Web, visit
	https://dev.eclipse.org/mailman/listinfo/eclipselink-users
or, via email, send a message with subject or body 'help' to
	eclipselink-users-request@xxxxxxxxxxx

You can reach the person managing the list at
	eclipselink-users-owner@xxxxxxxxxxx

When replying, please edit your Subject line so it is more specific
than "Re: Contents of eclipselink-users digest..."


Today's Topics:

   1. Re: RE: JBoss JNDI lookup issue around "Not a	compound name"
      (Michael O'Brien)
   2. Re: Using constructor injection with JPA entities (cowwoc)
   3. Re: Using constructor injection with JPA entities (Tom Ware)


----------------------------------------------------------------------

Message: 1
Date: Tue, 24 Feb 2009 13:53:43 -0500
From: "Michael O'Brien" <michael.obrien@xxxxxxxxxx>
Subject: Re: [eclipselink-users] RE: JBoss JNDI lookup issue around
	"Not a	compound name"
To: EclipseLink User Discussions <eclipselink-users@xxxxxxxxxxx>
Message-ID: <49A44237.4080101@xxxxxxxxxx>
Content-Type: text/plain; charset="utf-8"

Daoqi,
    1) If both changing the JTA datasource name and running as 
STRING_LOOKUP do not fix your issue then I suspect you are seeing some 
configuration issue with your datasource - or an issue running on Derby 
- as our examples run on Oracle 10/11.  We may need to retest on Derby 
to reproduce it. 
    Currently we are working fine on JBoss 4/5 using generic stateless 
session beans to inject the em and a servlet or java se client that 
either injects or looks up the session bean.

    Verify your jdbc global scoped datasource setup in the configuration

xml files on the server at
        
http://wiki.eclipse.org/EclipseLink/Examples/JPA/JBoss_Web_Tutorial#JBos
s_Server_Configuration_Changes

    See also a migration of the JBoss published jsfejb3.ear as an
example
        http://wiki.eclipse.org/EclipseLink/Examples/JPA/Migration/JBoss

    For an example of the generic JPA EAR project that is used in all 
our examples - you may refer to the WebLogic one that is the same except

for some configuration files and the SessionCustomizer. - until the 
JBoss specific ones are uploaded to SVN as part of bug# 250477
        
http://dev.eclipse.org/svnroot/rt/org.eclipse.persistence/trunk/examples
/org.eclipse.persistence.example.jpa.server.common.ddlgen/
        
http://dev.eclipse.org/svnroot/rt/org.eclipse.persistence/trunk/examples
/org.eclipse.persistence.example.jpa.server.weblogic.enterpriseEAR/
        
http://dev.eclipse.org/svnroot/rt/org.eclipse.persistence/trunk/examples
/org.eclipse.persistence.example.jpa.server.weblogic.enterpriseEJB/
        
http://dev.eclipse.org/svnroot/rt/org.eclipse.persistence/trunk/examples
/org.eclipse.persistence.example.jpa.server.weblogic.enterpriseWeb/


    2) Yes, the SessionCustomizer interface has been moved since the 
JBoss 4.2.2 based tutorial was written - it is now at the following 
config package location - wiki updated, thank you.
    There is an open bug# 260383 for servers based on the Catalina 
container that would add this JNDIConnector lookupType change into the 
platform class - you may vote for it - this would take the place of 
providing a SessionCustomizerImpl.  However this would only be after we 
verify whether JBoss 5 can run with COMPOSITE_NAME_LOOKUP which it looks

like it does.

org.eclipse.persistence.config.SessionCustomizer

The following bug is a proposed enhancement for a STRING_LOOKUP JNDI 
default for Catalina based servers
http://bugs.eclipse.org/260383


    I am running JBoss 4.2.2 (where the SessionCustomizer is required) 
but Kevin is running JBoss 5.0 GA (where we no longer require the 
SessionCustomizer)
    I will reverify for JBoss 5.0 GA and update the wiki and post any 
changes shortly as part of enhancement bugs bug# 252965 and bug# 250477

For reference:
The following ELUG wiki has been updated to reflect the new package name

- thank you
http://bugs.eclipse.org/229763
The following tutorial wiki bug is in progress for a test of JBoss 5.0
GA
http://bugs.eclipse.org/250477
The following bug is tracking our testing, documentation and possible 
platform change for the new JBoss 5.0 GA release
http://bugs.eclipse.org/252965

thank you
/michael


Kevin Yuan wrote:
  
Hi Daoqi,
I haven't SessionCustomizer in my persistence.xml, and the following 
is 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 
persistence_1_0.xsd" version="1.0">
    <persistence-unit name="default">
        
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
        <jta-data-source>java:/EclipseLinkDS</jta-data-source>
        <properties>
            <property name="eclipselink.target-server" value="JBoss"/>
            <property name="eclipselink.validate-existence"
    
value="true"/>
  
            <!--property name="eclipselink.logging.level" 
value="FINEST"/-->
        </properties>
    </persistence-unit>
</persistence>

*Regards,
Kevin*

*Yang, Daoqi (D.) wrote:
    
Kevin:

Regarding to the datasource issue in Jboss 5.0 GA, per your
      
sugestion, I tested with  
  
<jta-data-source>java:/jpaTestJtaDS</jta-data-source>

However, it still gives me the same error. You mentioned that it went
      
well when you tested EclipseLink with JBoss GA 5.0.
  
What is your EclipseLink and Jboss related configuration inside
      
persistence.xml? Did you configure a SessionCustomizer?
  
Do you mind sharing your persistence.xml file?

Michael:
Your suggestion to configure a SessionCustomer seems to be on the
      
right track so that EclipseLink JNDIConnector will be using
  
STRING_LOOKUP instead of "COMPOSITE_NAME_LOOKUP". However, when I
      
tried to define a session customizer, I found the base class
  
      
org.eclipse.persistence.internal.sessions.factories.SessionCustomizer;
  
No long exists in EclipseLin 1.0.2. I suspect that a common string
      
lookup session customizer class would be included with the distribution
of EclipseLink so that a developer can just configure it inside
persistence.xml without having to extending the base class. Is this the
case? If not, could you point out the new base class for session
customizers? 
  
Many thanks,


Regards,
Daoqi  Yang
Application Technology Architect
Ford Java Center of Excellence, E1F001 iTek
dyang11@xxxxxxxx, 313-206-3960

  
      
    
------------------------------------------------------------------------
  
_______________________________________________
eclipselink-users mailing list
eclipselink-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/eclipselink-users
  
    
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
https://dev.eclipse.org/mailman/private/eclipselink-users/attachments/20
090224/505eb5df/attachment.html

------------------------------

Message: 2
Date: Tue, 24 Feb 2009 21:41:35 -0800 (PST)
From: cowwoc <cowwoc@xxxxxxxxxxxxxxxx>
Subject: Re: [eclipselink-users] Using constructor injection with JPA
	entities
To: eclipselink-users@xxxxxxxxxxx
Message-ID: <22196690.post@xxxxxxxxxxxxxxx>
Content-Type: text/plain; charset=us-ascii


Hi,

As a follow-up to my previous post I have run across "O/R Broker" that
does
exactly what I am looking for. It allows one to query and persist
non-JavaBeans objects. Please see http://orbroker.sourceforge.net/ and
http://orbroker.sourceforge.net/documentation/user-guide.shtml

This project has been dead for a few years now but I don't see anything
stopping us from applying the same techniques in JPA. If I understand
correctly, all we'd need to do is mark up constructor parameters using
@Column to indicate what database column should go into each parameter.
This
seems simple enough. What do you think?

Gili


cowwoc wrote:
  
Hi,

I am curious whether it conceivably possible for JPA 2.0 to add
    
support
  
for constructor injection for such things as read-only entities. I'm
    
not a
  
fan of the JavaBean design pattern and I'm wondering whether it would
    
be
  
possible to move EclipseLink and JPA closer to the Guice way of doing
things. For example:

class Foo
{
  public Foo(@Named("username") String username, @Named("password")
    
String
  
password)
  {}

  // mapping annotations go on getters
  public String getUsername() {}
  public String getPassword() {}

  // no setters
}

It would be even better if you could pick up the property names
    
directly
  
from the variable name but I believe there are technical problems with
that approach.

Thank you,
Gili

    
  


Back to the top