Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » ReadAllQuery in 2-tier Swing App
ReadAllQuery in 2-tier Swing App [message #385268] Fri, 16 January 2009 20:52 Go to next message
David J Rericha is currently offline David J RerichaFriend
Messages: 13
Registered: July 2009
Junior Member
Dear members,

I have apparently successfully executed the following ReadAllQuery in a
Swing App:

public static List<Patient> getPatients( final Patient p, final
EntityManager em )
{
ReadAllQuery query = new ReadAllQuery( Patient.class );
ExpressionBuilder builder = query.getExpressionBuilder();
query.setExampleObject( p );

QueryByExamplePolicy policy = new QueryByExamplePolicy();
policy.excludeValue( Entity.UNASSIGNED );
policy.addSpecialOperation( String.class, "likeIgnoreCase" );
query.setQueryByExamplePolicy( policy );
query.addOrdering( builder.get( "lastName" ).ascending() );
query.addOrdering( builder.get( "firstName" ).ascending() );
JpaEntityManager jpaEm = (JpaEntityManager)em.getDelegate();
return (List<Patient>)jpaEm.getActiveSession().executeQuery( query );
}

My question concerns:
JpaEntityManager jpaEm = (JpaEntityManager)em.getDelegate();
jpaEm.getActiveSession();

I could not find this manner of retrieving the session in the ELUG so I
want to make sure that it is valid for my configuration:

<?xml version="1.0" encoding="UTF-8"?>
<persistence version="1.0"
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
http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd">
<persistence-unit name="quickstart-eclipselink"
transaction-type="RESOURCE_LOCAL">
<class>com.oss.quickstart.models.Doctor</class>
<class>com.oss.quickstart.models.Model</class>
<class>com.oss.quickstart.models.Patient</class>
<class>com.oss.quickstart.models.Address</class>
<exclude-unlisted-classes>true</exclude-unlisted-classes>
<properties>
<property name="eclipselink.jdbc.url"
value="jdbc:postgresql://localhost/moms-test"/>
<property name="eclipselink.jdbc.user" value="postgres"/>
<property name="eclipselink.jdbc.password" value=""/>
<property name="eclipselink.jdbc.driver"
value="org.postgresql.Driver"/>
<property name="eclipselink.logging.level" value="FINE"/>
<property name="eclipselink.ddl-generation.output-mode"
value="both"/>
<property name="eclipselink.target-database"
value="PostgreSQL"/>
<property name="eclipselink.jdbc.read-connections.min"
value="1"/>
<property name="eclipselink.jdbc.read-connections.max"
value="1"/>
<property name="eclipselink.jdbc.write-connections.min"
value="1"/>
<property name="eclipselink.jdbc.write-connections.max"
value="1"/>
<property name="eclipselink.cache.shared.default"
value="false"/>
</properties>
</persistence-unit>
</persistence>
Re: ReadAllQuery in 2-tier Swing App [message #385289 is a reply to message #385268] Mon, 19 January 2009 13:34 Go to previous message
James Sutherland is currently offline James SutherlandFriend
Messages: 1939
Registered: July 2009
Location: Ottawa, Canada
Senior Member

Using getActiveSession() is correct.

----
James
http://www.nabble.com/EclipseLink---Users-f26658.html


James : Wiki : Book : Blog : Twitter
Previous Topic:NullPointerException for all non Embedded classes
Next Topic:ddl generation without jpa
Goto Forum:
  


Current Time: Thu Apr 18 14:46:32 GMT 2024

Powered by FUDForum. Page generated in 0.01852 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top