-1

Recently We have migrated from Jboss4.2 to Jboss 7.2. Exact same HQL query is running fine for Jboss4.2. But in Jboss7.2 HQL query is not running properly in Jboss7.2, it's giving error that I have mentioned below:

no persistent classes found for query class: SELECT distinct
pf.projectFormId FROM com.gsk.rd.craw.model.ProjectForm pf   left join
pf.contacts c WHERE pf.createdBy=:mudid OR pf.modifiedBy=:mudid OR
c.mudid=:mudid 

java.lang.IllegalArgumentException:
org.hibernate.QueryParameterException: could not locate named
parameter



18:33:04,338 TRACE [org.hibernate.engine.query.spi.QueryPlanCache]
(http-/127.0.0.1:8080-1) Unable to locate HQL query plan in cache;
generating (SELECT distinct pf.projectFormId FROM
com.gsk.rd.craw.model.ProjectForm pf   left join pf.contacts c WHERE
pf.createdBy=:mudid OR pf.modifiedBy=:mudid OR c.mudid=:mudid )
18:33:04,338 TRACE [org.jboss.modules] (http-/127.0.0.1:8080-1)
Finding class com.gsk.rd.craw.model.ProjectForm from Module
"deployment.craw.ear:main" from Service Module Loader 18:33:04,338
TRACE [org.jboss.modules] (http-/127.0.0.1:8080-1) Finding local class
com.gsk.rd.craw.model.ProjectForm from Module
"deployment.craw.ear.craw_jar.jar:main" from Service Module Loader
18:33:04,338 TRACE [org.jboss.modules] (http-/127.0.0.1:8080-1) Found
previously loaded class com.gsk.rd.craw.model.ProjectForm from Module
"deployment.craw.ear.craw_jar.jar:main" from Service Module Loader
18:33:04,339 WARN  [org.hibernate.hql.internal.QuerySplitter]
(http-/127.0.0.1:8080-1) HHH000183: no persistent classes found for
query class: SELECT distinct pf.projectFormId FROM
com.gsk.rd.craw.model.ProjectForm pf   left join pf.contacts c WHERE
pf.createdBy=:mudid OR pf.modifiedBy=:mudid OR c.mudid=:mudid 
18:33:04,339 INFO  [stdout] (http-/127.0.0.1:8080-1)
0000000000000000000000000000000003333333333333333333333333


18:33:04,346 TRACE [org.jboss.modules] (http-/127.0.0.1:8080-1)
Finding local class org.hibernate.internal.AbstractQueryImpl from
Module "org.hibernate:main" from local module loader @3c20902c
(finder: local module finder @7dd9578a (roots:
D:\CRAW_JBOSS7.2\aries-sandbox\jboss-as-7.2.0.Final\modules,D:\CRAW_JBOSS7.2\aries-sandbox\jboss-as-7.2.0.Final\modules\system\layers\base))
18:33:04,346 TRACE [org.jboss.modules] (http-/127.0.0.1:8080-1) Found
previously loaded class org.hibernate.internal.AbstractQueryImpl from
Module "org.hibernate:main" from local module loader @3c20902c
(finder: local module finder @7dd9578a (roots:
D:\CRAW_JBOSS7.2\aries-sandbox\jboss-as-7.2.0.Final\modules,D:\CRAW_JBOSS7.2\aries-sandbox\jboss-as-7.2.0.Final\modules\system\layers\base))
18:33:04,341 SEVERE [facelets.viewhandler] (http-/127.0.0.1:8080-1)
Error Rendering View[/ProjectFormCatalog.jsp]:
java.lang.IllegalArgumentException:
org.hibernate.QueryParameterException: could not locate named
parameter [mudid]

We have upgraded:

  • Java from jdk1.5 to jdk1.7,
  • Hibernate 3 to Hibernate 4,
  • JPA 1 we have used for both version,
  • EJB 3 we have used for both version
halfer
  • 19,824
  • 17
  • 99
  • 186
  • this should be an issue with the maintainers, not the stack community. Additionally, you have not provided any real code to help anyone solve the issue. – Rafael Dec 26 '16 at 18:37
  • I please find the code **below** @SuppressWarnings("unchecked") private List getProjectFormIdsByContact() { String sql = "SELECT distinct pf.projectFormId " + "FROM com.gsk.rd.craw.model.ProjectForm pf " + " left join pf.contacts c " + "WHERE pf.createdBy=:mudid " + "OR pf.modifiedBy=:mudid " + "OR c.mudid=:mudid "; Query query = entityManager.createQuery(sql); query.setParameter("mudid", mudId); return query.getResultList(); } – user3391496 Jan 04 '17 at 14:48
  • This same query is working fine for Jboss 4.2. – user3391496 Jan 04 '17 at 14:48

2 Answers2

0

Check your HQL query syntax whether mudid is really a database column name/hibernate Entity property name available or not?

Anup Dey
  • 876
  • 5
  • 6
  • Yea same query , its Running fine in Jboss 4.2 but i am geeting error in Jboss 7.2 I have mentioned query below. String sql = "SELECT distinct pf.projectFormId " + "FROM com.gsk.rd.craw.model.ProjectForm pf " + " left join pf.contacts c " + "WHERE pf.createdBy=:mudid " + "OR pf.modifiedBy=:mudid " + "OR c.mudid=:mudid "; Query query = entityManager.createQuery(sql); – user3391496 Jan 04 '17 at 10:22
  • I am using the same query for both Jboss version. I have mentioned the query above. Dont know what is the issue , same query running fine in Jboss 4.2. Please help me. I am new in Jboss environment. – user3391496 Jan 04 '17 at 12:46
  • There are a lot of difference between Jboss 4.2 to JBoss 7.2. Also Hibernate and JPA versions. Paste the hibernate entity class "com.gsk.rd.craw.model.ProjectForm.java" to review? – Anup Dey Jan 04 '17 at 12:58
  • **Thanks for your HELP** PLEASE find the hibernate entity class "com.gsk.rd.craw.model.ProjectForm.java" BELOW ** – user3391496 Jan 04 '17 at 14:52
  • "com.gsk.rd.craw.model.ProjectForm.java" hibernate entity class have more than 900 lines so, unable to paste it here. – user3391496 Jan 04 '17 at 14:54
  • Hi, I can't find the source code of "com.gsk.rd.craw.model.ProjectForm.java" just want see the skeleton of the Entity class. Copy starting from class name and its properties and paste it here. – Anup Dey Jan 05 '17 at 05:13
  • I am pasting it here in part wise. (PART 1) – user3391496 Jan 05 '17 at 07:25
  • package com.gsk.rd.craw.model; import java.security.Principal; import java.util.ArrayList; import java.util.Collections; import java.util.Date; import java.util.HashSet; import java.util.List; import java.util.Set; import javax.persistence.CascadeType; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.FetchType; import javax.persistence.GeneratedValue; import javax.persistence.Id; import javax.persistence.JoinColumn; import javax.persistence.JoinTable; import javax.persistence.ManyToMany; – user3391496 Jan 05 '17 at 07:27
  • import javax.persistence.ManyToMany; import javax.persistence.ManyToOne; import javax.persistence.NamedQueries; import javax.persistence.NamedQuery; import javax.persistence.OneToMany; import javax.persistence.SequenceGenerator; import javax.persistence.Table; import javax.persistence.Temporal; import javax.persistence.TemporalType; import javax.persistence.Transient; import org.apache.commons.lang.ObjectUtils; import org.apache.commons.lang.StringUtils; import org.hibernate.annotations.Cache; import org.hibernate.annotations.CacheConcurrencyStrategy; – user3391496 Jan 05 '17 at 07:28
  • import org.hibernate.annotations.IndexColumn; import org.hibernate.collection.PersistentSet; import org.hibernate.validator.Length; import org.hibernate.validator.NotNull; import com.gsk.rd.aries.common.security.SecurityUtil; import com.gsk.rd.craw.workflow.Workflow; import com.gsk.rd.craw.workflow.WorkflowState; import com.gsk.rd.craw.workflow.Workflowable; /** * ProjectForm generated by hbm2java */ – user3391496 Jan 05 '17 at 07:28
  • @Entity(name="com.gsk.rd.craw.model.ProjectForm") @Table(name = "PROJECT_FORM") @NamedQueries(value = { @NamedQuery(name = "findProjectFormBySow", query = "from com.gsk.rd.craw.model.ProjectForm p where p.sow in(:sow)") }) @Cache(usage=CacheConcurrencyStrategy.READ_WRITE) public class ProjectForm extends ModifiableEntity implements Workflowable { private static final long serialVersionUID = 1L; private long projectFormId; private ServiceType serviceType; private Sow sow; private Cro cro; – user3391496 Jan 05 '17 at 07:28
  • private String lnbWorkRequestId; private Date lnbWorkRequestVer; private Integer lnbWorkRequestVersion = Integer.valueOf(1); private Date submittedDate; private String submittedBy; private String submitterEmail; private String submitterPhone; private OrgUnit businessOrgUnit; private OrgUnit organizationOrgUnit; private OrgUnit departmentOrgUnit; private String site; private Long projectId; private String projectName; – user3391496 Jan 05 '17 at 07:29
  • private String projectDiseaseArea; private Date requestedDeliveryDate; private Date estimatedDeliveryDate; private Date actualDeliveryDate; private WorkflowState workflowState; private Date approvedDate; private Date submittedToCroDate; private Date acceptedByCroDate; private String description; private Double estimatedCroScientists; private Double actualCroScientists; private Date croChemistAssignedDate; private String estimatedDuration; private Priority priority; private String coordinatedBy; – user3391496 Jan 05 '17 at 07:30
  • private String croLead; private Date agreedDueDate; private Date completionDate; private Date estimatedStartDate; private Date actualStartDate; private String croTrainingStatus; private String analyticalFileStatus; private Date lastNotebookReviewDate; private Category category; private Precedence precedence; private String literatureReferences; private String createdBy; private Date createdDate; private Set attachments = new HashSet(0); – user3391496 Jan 05 '17 at 07:30
  • private Set contacts = new HashSet(0); private Set pfComments = new HashSet(0); private List compoundSpecifications = new ArrayList(0); private String displayName; private boolean multiple; private Set projectTable = new HashSet(0); – user3391496 Jan 05 '17 at 07:31
  • public ProjectForm () { } public ProjectForm (String lnbWorkRequestId) { String username = "CRAW";//(principal != null ? principal.getName() : "CRAW"); Date date = new Date(); Workflow workflow = Workflow.getInstance(); this.lnbWorkRequestId = lnbWorkRequestId; this.workflowState = workflow.getInitialState(); this.submittedDate = date; this.createdBy = username; this.createdDate = date; if ( username != null ) { setSubmittedBy( username ); } } – user3391496 Jan 05 '17 at 07:32
  • **@Id @GeneratedValue(generator = "PROJECT_FORM_SEQ") @SequenceGenerator(name = "PROJECT_FORM_SEQ", sequenceName = "PROJECT_FORM_SEQ", allocationSize = 1) @Column(name = "PROJECT_FORM_ID", unique = true, nullable = false, precision = 15, scale = 0) @NotNull public long getProjectFormId() { return this.projectFormId; } public void setProjectFormId(long projectFormId) { this.projectFormId = projectFormId; } public void setMultiple(boolean multiple) { this.multiple = multiple; }** – user3391496 Jan 05 '17 at 07:33
  • You need to verify how you're doing your one-to many relationship mapping. "private Set contacts = new HashSet(0); " : Here you didn't configure any mapping properties. – Anup Dey Jan 05 '17 at 10:42
  • How to configure any mapping properties here please suggest? – user3391496 Jan 05 '17 at 11:10
  • See my response in the Answers section. I have pasted sample code snippet in Answers section. – Anup Dey Jan 05 '17 at 11:16
0

Example of a OneToMany relationship and inverse ManyToOne annotations

@Entity
public class ProjectForm ....
...
@Id
@Column(name="PF_ID")
private long projectFormId;
...
@OneToMany(mappedBy="projectForm", cascade = { CascadeType.ALL})
private Set<Contact> contacts = new HashSet<Contact>();
...


@Entity
public class Contact ...
...
@ManyToOne(cascade= {CascadeType.ALL} , fetch=FetchType.LAZY)
@JoinColumn(name="PROJECTFORM_CONTACT")
private ProjectForm projectForm;
...
Anup Dey
  • 876
  • 5
  • 6
  • Not getting it. Tried but still the same issue. – user3391496 Jan 05 '17 at 13:40
  • Provide the java source code of Contact entity class with mapping properties with ProjectForm entity class. Only mapping section paste it – Anup Dey Jan 05 '17 at 14:15
  • **unable to paste it because so many notation "@" is used For this I am unable to paste it here. @ManyToOne @JoinColumn(name = "SOW_ID") public Sow getSow() { return this.sow; }** – user3391496 Jan 05 '17 at 14:48
  • any other way is there to paste the code snippet ?? – user3391496 Jan 05 '17 at 14:49
  • Where mudid property is present? In which entity class. Is there any relationship established between ProjectForm entity class. If yes put it here how the relationship been established between them? In this Query: "left join pf.contacts c " + "WHERE pf.createdBy=:mudid " + "OR pf.modifiedBy=:mudid " + "OR c.mudid=:mudid ": check the "mudid" is actually a DB column and entity class property.? – Anup Dey Jan 05 '17 at 15:01
  • Is "mudid" a property of Contact Entity class? How do you establish the relationship between ProjectForm and Contact entity class on both side? – Anup Dey Jan 05 '17 at 15:10
  • Yes its present. The problem is same query is working fine in Jboss 4.2 but for 7.2 I am getting error. For both we are using same table and column. – user3391496 Jan 05 '17 at 15:11
  • **@Id @GeneratedValue(generator = "CONTACT_SEQ") @SequenceGenerator(name = "CONTACT_SEQ", sequenceName = "CONTACT_SEQ", allocationSize = 1) @Column(name = "CONTACT_ID", unique = true, nullable = false, precision = 15, scale = 0) @NotNull public long getContactId() { return this.contactId; } public void setContactId(long contactId) { this.contactId = contactId; } ** – user3391496 Jan 05 '17 at 15:13
  • public class ProjectForm ... private Set contacts = new HashSet(0); How do you establish the relationship between ProjectForm and Contact ? – Anup Dey Jan 05 '17 at 15:14
  • `@Column(name = "MUDID", nullable = false, length = 200) @NotNull @Length(max = 200) public String getMudid() { return this.mudid; } void setMudid(String mudid) { this.mudid = mudid; } @ManyToOne(fetch = FetchType.EAGER) @JoinColumn(name = "CONTACT_ROLE_ID", nullable=false) @NotNull public ContactRole getContactRole() { return this.contactRole; } void setContactRole(ContactRole contactRole) { this.contactRole = contactRole; }` THE ABOVE SNIPPETS ARE FROM CONTACT ENTITY – user3391496 Jan 05 '17 at 15:15
  • `@Transient public Contact getCoordinatorContact () { return getContactByRole( ContactRole.getCoordinatorInstance() ); } @Column(name = "COORDINATED_BY", length = 100) @Length(max = 100) public String getCoordinatedBy() { return this.coordinatedBy; } public void setCoordinatedBy(String mudid) { this.coordinatedBy = StringUtils.stripToNull( mudid ); setContact( coordinatedBy, ContactRole.getCoordinatorInstance() ); }` – user3391496 Jan 05 '17 at 15:18
  • Is there setter/getter methods present of "Set " and mapping in ProjectForm.java? – Anup Dey Jan 05 '17 at 15:35
  • Have you established the mapping relationship details in the setter/getter methods of "Set = " in ProjectForm.java? If yes, paste it only their relationship made. Similarly, I believe that you surely have established the relationship in Contact Entity class with ProjectForm Entity class. I want to see how you made the relationship in between? Paste it here only relationship mapping details. – Anup Dey Jan 06 '17 at 05:07