ReadAllQuery in 2-tier Swing App [message #385268] |
Fri, 16 January 2009 15:52  |
Eclipse User |
|
|
|
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>
|
|
|
|
Powered by
FUDForum. Page generated in 0.05491 seconds