Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[eclipselink-users] hanging query

Hi All,

I have a problem with hanging queries in my application. The scenario is following:

 

There are two JPA entities PackageJPAEntity and RuleDefinitionJPAEntity mapped to corresponding tables in an Oracle 10g DB. We have also a stateless session bean called RulePersistenceManagerBean acting as web service that contains the business methods.

The application is running in a glassfish application server on linux.

 

The classes are annotated as follows:

 

@Stateless(name="RulePersistenceManager", mappedName="ejb/RulePersistenceManager")

@TransactionManagement(TransactionManagementType.CONTAINER)

@TransactionAttribute(TransactionAttributeType.REQUIRED)

public class RulePersistenceManagerBean implements …..

……………

    @PersistenceContext(unitName="rulePersistencePu")

    protected EntityManager em;

 

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

 

@Entity

@Table(name="PACKAGE", schema="ISE", uniqueConstraints={

        @UniqueConstraint(columnNames={"PACKAGE_NAME"}),

        @UniqueConstraint(columnNames={"PACKAGE_CODE"})})

@NamedQueries({

    @NamedQuery(name=PackageJPAEntity.FIND_BY_NAME,

        query="SELECT p FROM PackageJPAEntity p WHERE p.name=:name"),

    @NamedQuery(name=PackageJPAEntity.FIND_ALL,

        query="SELECT p FROM PackageJPAEntity p ")})

public class PackageJPAEntity implements Package, Serializable {

 

…………………..

    @OneToMany(cascade={CascadeType.MERGE, CascadeType.PERSIST, CascadeType.REMOVE},

        mappedBy="owningPackage", targetEntity=RuleDefinitionJPAEntity.class, fetch=FetchType.LAZY)

    protected Set<RuleDefinition> ruleDefinitions;

…………………………

 

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

 

@Entity

@Table(name="RULE", schema="ISE", uniqueConstraints={

        @UniqueConstraint(columnNames={"PACKAGE_ID", "RULE_NAME"})})

@NamedQueries({

    @NamedQuery(name=RuleDefinitionJPAEntity.FIND_BY_NAME,

        query="SELECT r FROM RuleDefinitionJPAEntity AS r JOIN r.owningPackage p " +

        " WHERE r.ruleName = :ruleName AND p.name = :packageName")})

public class RuleDefinitionJPAEntity implements

…………………

    @ManyToOne(targetEntity=PackageJPAEntity.class, fetch=FetchType.LAZY)

    @JoinColumn(name="PACKAGE_ID", nullable=false, referencedColumnName="PACKAGE_ID")

    protected com.fortent.ise.rule.model.storage.Package owningPackage;

………………..

 

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

 

 

There are also more attributes in the entities but I have extracted only the interesting ones.

Under some unpredictable circumstances we don’t get any response when getSingleResult is called on a query object.

 

As example two methods from the RulePersistenceManager bean:  

 

    public RuleElement getRuleDefinition( String packageName,

            String ruleName) {

        System.out.println("*** getRuleDefinition ***");

        RuleElement rule = null;

        em.clear();

        RuleDefinitionJPAEntity ruleEntity =

                getRuleDefinitionFromDB(packageName, ruleName);

        rule = helper.getRuleDTO(ruleEntity);

        return rule;

    }

 

    /*

     * Get rule definition entity from db

     */

    private RuleDefinitionJPAEntity getRuleDefinitionFromDB(

            String packageName, String ruleName){

        RuleDefinitionJPAEntity result;

        System.out.println("getRuleDefinitionFromDB: " + packageName + " ; " + ruleName );

        try{

            Query q = em.createNamedQuery(RuleDefinitionJPAEntity.FIND_BY_NAME);

            q.setParameter(RuleDefinitionJPAEntity.PACKAGE_NAME_PARAMETER, packageName);

            q.setParameter(RuleDefinitionJPAEntity.RULE_NAME_PARAMETER, ruleName);

            System.out.println("getRuleDefinitionFromDB query: before " + q);

            result = (RuleDefinitionJPAEntity)q.getSingleResult();

            System.out.println("getRuleDefinitionFromDB query: after " + q);

        return result;

    }    

 

And the corresponding part from the log:

 

 

[#|2009-02-12T15:10:38.250+0000|INFO|sun-appserver9.1|javax.enterprise.system.stream.out|_ThreadID=77;_ThreadName=httpSSLWorkerThread-8080-2;|

*** getRuleDefinition ***|#]

 

[#|2009-02-12T15:10:38.250+0000|INFO|sun-appserver9.1|javax.enterprise.system.stream.out|_ThreadID=77;_ThreadName=httpSSLWorkerThread-8080-2;|

getRuleDefinitionFromDB: GeneralFraud ; PriceDisimprovement|#]

 

[#|2009-02-12T15:10:38.251+0000|FINER|sun-appserver9.1|org.eclipse.persistence.session.file:/root/GlassFishESB/glassfish/domains/domain1/applications/j2ee-apps/iseEAR/rulePersistenceManagerWS-0.0.1-SNAPSHOT_jar/-rulePersistencePu.connection|_ThreadID=77;_ThreadName=httpSSLWorkerThread-8080-2;ClassName=null;MethodName=null;_RequestID=c039ac6f-da1d-4974-ab86-475771cbce8a;|client acquired|#]

 

[#|2009-02-12T15:10:38.251+0000|FINER|sun-appserver9.1|org.eclipse.persistence.session.file:/root/GlassFishESB/glassfish/domains/domain1/applications/j2ee-apps/iseEAR/rulePersistenceManagerWS-0.0.1-SNAPSHOT_jar/-rulePersistencePu.transaction|_ThreadID=77;_ThreadName=httpSSLWorkerThread-8080-2;ClassName=null;MethodName=null;_RequestID=c039ac6f-da1d-4974-ab86-475771cbce8a;|TX binding to tx mgr, status=STATUS_ACTIVE|#]

 

[#|2009-02-12T15:10:38.251+0000|INFO|sun-appserver9.1|javax.enterprise.system.stream.out|_ThreadID=77;_ThreadName=httpSSLWorkerThread-8080-2;|

getRuleDefinitionFromDB query: before org.eclipse.persistence.internal.jpa.EJBQueryImpl@e415726|#]

 

[#|2009-02-12T15:10:38.251+0000|FINEST|sun-appserver9.1|org.eclipse.persistence.session.file:/root/GlassFishESB/glassfish/domains/domain1/applications/j2ee-apps/iseEAR/rulePersistenceManagerWS-0.0.1-SNAPSHOT_jar/-rulePersistencePu.query|_ThreadID=77;_ThreadName=httpSSLWorkerThread-8080-2;ClassName=null;MethodName=null;_RequestID=c039ac6f-da1d-4974-ab86-475771cbce8a;|Execute query ReadAllQuery(com.fortent.ise.rule.component.storage.RuleDefinitionJPAEntity)|#]

 

[#|2009-02-12T15:10:38.252+0000|FINEST|sun-appserver9.1|org.eclipse.persistence.session.file:/root/GlassFishESB/glassfish/domains/domain1/applications/j2ee-apps/iseEAR/rulePersistenceManagerWS-0.0.1-SNAPSHOT_jar/-rulePersistencePu.connection|_ThreadID=77;_ThreadName=httpSSLWorkerThread-8080-2;ClassName=null;MethodName=null;_RequestID=c039ac6f-da1d-4974-ab86-475771cbce8a;|reconnecting to external connection pool|#]

 

[#|2009-02-12T15:10:38.252+0000|FINE|sun-appserver9.1|org.eclipse.persistence.session.file:/root/GlassFishESB/glassfish/domains/domain1/applications/j2ee-apps/iseEAR/rulePersistenceManagerWS-0.0.1-SNAPSHOT_jar/-rulePersistencePu.sql|_ThreadID=77;_ThreadName=httpSSLWorkerThread-8080-2;ClassName=null;MethodName=null;_RequestID=c039ac6f-da1d-4974-ab86-475771cbce8a;|SELECT t0.RULE_ID, t0.RULE_NAME, t0.DESCRIPTION, t0.CREATED, t0.LAST_UPDATED, t0.IN_MESSAGE_TYPE_ID, t0.OUT_MESSAGE_TYPE_ID, t0.PACKAGE_ID FROM ISE.RULE t0, ISE.PACKAGE t1 WHERE (((t0.RULE_NAME = ?) AND (t1.PACKAGE_NAME = ?)) AND (t1.PACKAGE_ID = t0.PACKAGE_ID))

            bind => [PriceDisimprovement, GeneralFraud]|#]

 

At this point the program hangs. There are no DB locks and no active sessions in the DB, but the call to q.getSingleResult() doesn’t return and we must restart the application server to get over this.

I think that there is some kind of locking issue.

Is there something principally wrong in my approach?

The main problem is – it is not reproducible. Sometimes it works and sometimes not.

 

We would appreciate any help.

 

Cheers

Peter Szaniszlo 
Software Developer

Fortent
Pu
škinova 3
040 01
Košice, Slovakia

www.fortent.com

 


Back to the top