-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 16 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: Reterving Data from database getting exception ...
PostPosted: Sat Feb 13, 2010 1:20 pm 
Newbie

Joined: Sat Feb 13, 2010 1:04 pm
Posts: 10
Environment:

JDK : 1.6.0.10
Tomcat : 6.0.18
MYSQL : 5.1
Hibernate Annotation with JPA.

when i try to reterve data i am getting this Exception :


java.lang.Exception: Unable to get required data expecting IDENT, found '1233435' near line 1, column 480 [select pa.id,pa.serviceRecordNo,pa.modelId,mdl.serviceModelName,pa.productCategory,pc.prodCategoryName,pa.branchId,branch.branchLocation,pa.dateRecieve,pa.dateOfDelivery,pa.userId,usr.name from PendingAssign pa ,Model mdl,ProductCategory pc,Branch branch,User usr where mdl.nextSequence = pa.modelId and pc.productCategoryId=mdl.productCategory and mdl.productCategory=pa.productCategory and branch.actualBranchId = pa.branchId and usr.userId = pa.userId and pa.serviceRecordNo=:1233435]; nested exception is org.hibernate.hql.ast.QuerySyntaxException: expecting IDENT, found '1233435' near line 1, column 480 [select pa.id,pa.serviceRecordNo,pa.modelId,mdl.serviceModelName,pa.productCategory,pc.prodCategoryName,pa.branchId,branch.branchLocation,pa.dateRecieve,pa.dateOfDelivery,pa.userId,usr.name from PendingAssign pa ,Model mdl,ProductCategory pc,Branch branch,User usr where mdl.nextSequence = pa.modelId and pc.productCategoryId=mdl.productCategory and mdl.productCategory=pa.productCategory and branch.actualBranchId = pa.branchId and usr.userId = pa.userId and pa.serviceRecordNo=:1233435]
com.ssms.dao.common.HibernateExecutionTemplate.getSelectiveDataFromDataStoredForDynamicQuery(HibernateExecutionTemplate.java:128)
com.ssms.dao.repair.PendingAssignDAOImpl.getPending(PendingAssignDAOImpl.java:50)
com.ssms.services.repair.PendingAssignServiceImpl.getPending(PendingAssignServiceImpl.java:19)
com.ssms.web.actions.repair.PendingAssignAction.execute(PendingAssignAction.java:21)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
java.lang.reflect.Method.invoke(Unknown Source)


Model class :

@Entity
@Table(name="repair_pending_assign")
public class PendingAssign implements Serializable {

private static final long serialVersionUID = 2751938052191272938L;

@Id
@GeneratedValue(strategy=GenerationType.AUTO)
@Column
private Long id;

@Column
private String serviceRecordNo;

@Column
private int modelId;

@Column
private int productCategory;

@Column
private int branchId;

@Column
private Date dateRecieve;

@Column
private Date dateOfDelivery;

@Column
private String assign;

@Column
private int userId;


/**
* @return the serviceRecordNo
*/
public String getServiceRecordNo() {
return serviceRecordNo;
}

/**
* @param serviceRecordNo the serviceRecordNo to set
*/
public void setServiceRecordNo(String serviceRecordNo) {
this.serviceRecordNo = serviceRecordNo;
}

/**
* @return the modelId
*/
public int getModelId() {
return modelId;
}

/**
* @param modelId the modelId to set
*/
public void setModelId(int modelId) {
this.modelId = modelId;
}

/**
* @return the productCategory
*/
public int getProductCategory() {
return productCategory;
}

/**
* @param productCategory the productCategory to set
*/
public void setProductCategory(int productCategory) {
this.productCategory = productCategory;
}

/**
* @return the dateRecieve
*/
public Date getDateRecieve() {
return dateRecieve;
}

/**
* @param dateRecieve the dateRecieve to set
*/
public void setDateRecieve(Date dateRecieve) {
this.dateRecieve = dateRecieve;
}

/**
* @return the dateOfDelivery
*/
public Date getDateOfDelivery() {
return dateOfDelivery;
}

/**
* @param dateOfDelivery the dateOfDelivery to set
*/
public void setDateOfDelivery(Date dateOfDelivery) {
this.dateOfDelivery = dateOfDelivery;
}

/**
* @return the assign
*/
public String getAssign() {
return assign;
}

/**
* @param assign the assign to set
*/
public void setAssign(String assign) {
this.assign = assign;
}

/**
* @return the userId
*/
public int getUserId() {
return userId;
}

/**
* @param userId the userId to set
*/
public void setUserId(int userId) {
this.userId = userId;
}

/**
* @return the branchId
*/
public int getBranchId() {
return branchId;
}

/**
* @param branchId the branchId to set
*/
public void setBranchId(int branchId) {
this.branchId = branchId;
}

/**
* @return the id
*/
public Long getId() {
return id;
}

/**
* @param id the id to set
*/
public void setId(Long id) {
this.id = id;
}




DAO Class :


public List<PendingAssignBO> getPending(String queryString, String searchBy)
throws Exception {

List<String> paramNames = new ArrayList<String>();
paramNames.add(queryString);

List<Object> values = new ArrayList<Object>();
values.add(queryString);

StringBuffer query = new StringBuffer();

query.append("select pa.id,pa.serviceRecordNo,pa.modelId,mdl.serviceModelName,pa.productCategory,");
query.append("pc.prodCategoryName,pa.branchId,branch.branchLocation,pa.dateRecieve,pa.dateOfDelivery,pa.userId,usr.name ");
query.append("from PendingAssign pa ,Model mdl,");
query.append("ProductCategory pc,Branch branch,");
query.append("User usr ");
query.append("where mdl.nextSequence = pa.modelId and pc.productCategoryId=mdl.productCategory and ");
query.append("mdl.productCategory=pa.productCategory and branch.actualBranchId = pa.branchId and ");
query.append("usr.userId = pa.userId and pa."+searchBy+"=:"+queryString);


RepairAssignMapper repairAssignMapper = new RepairAssignMapper();

return repairAssignMapper.getPendingAssignMapper(hibernateDataTemplate.
getSelectiveDataFromDataStoredForDynamicQuery(query.toString(), paramNames, values));

}


getSelectiveDataFromDataStoredForDynamicQuery Method :

public List getSelectiveDataFromDataStoredForDynamicQuery(String query, List<String>paramNames, List<Object> values) throws Exception{
List returnedList = new ArrayList();
try {
returnedList = getHibernateTemplate().findByNamedParam(query, getStringArray(paramNames), getObjectArray(values));
} catch (DataAccessException e) {
throw new Exception("Unable to get required data "+ e.getMessage());
}
return returnedList;
}


i am having this issue for nearly one week can anyone say me what i am doing wrong .


Top
 Profile  
 
 Post subject: Re: Reterving Data from database getting exception ...
PostPosted: Sat Feb 13, 2010 6:38 pm 
Expert
Expert

Joined: Wed Mar 03, 2004 6:35 am
Posts: 1240
Location: Lund, Sweden
The problem is with this part of your code: pa."+searchBy+"=:"+queryString

It seems like queryString has a value of '1233435', which results in the following in the query: pa.serviceRecordNo=:1233435

In HQL, : is used to indicate a named parameter, and a name must at least start with a letter. I am not really sure about what kind of query you are trying to put together, but I assume that the '1233435' is the value you are looking for. Something like this would be better.

Code:
... pa."+searchBy+"=:searchValue"


And then, I am not sure how your code works... but could it be that it is as simple as this?

Code:
parameNames.add("searchValue");
values.add(1233435);


Top
 Profile  
 
 Post subject: Re: Reterving Data from database getting exception ...
PostPosted: Sun Feb 14, 2010 12:51 am 
Newbie

Joined: Sat Feb 13, 2010 1:04 pm
Posts: 10
nordborg , thanks for your reply i have changed as mentioned but still getting error ...


java.lang.Exception: Unable to get required data could not locate named parameter [searchValue]; nested exception is org.hibernate.QueryParameterException: could not locate named parameter [searchValue]
com.ssms.dao.common.HibernateExecutionTemplate.getSelectiveDataFromDataStoredForDynamicQuery(HibernateExecutionTemplate.java:128)
com.ssms.dao.repair.PendingAssignDAOImpl.getPending(PendingAssignDAOImpl.java:49)
com.ssms.services.repair.PendingAssignServiceImpl.getPending(PendingAssignServiceImpl.java:19)
com.ssms.web.actions.repair.PendingAssignAction.execute(PendingAssignAction.java:21)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
java.lang.reflect.Method.invoke(Unknown Source)


DAO class :

List<String> paramNames = new ArrayList<String>();
paramNames.add("searchValue");

List<Object> values = new ArrayList<Object>();
values.add(queryString);

StringBuffer query = new StringBuffer();

query.append("select pa.id,pa.serviceRecordNo,pa.modelId,mdl.serviceModelName,pa.productCategory,");
query.append("pc.prodCategoryName,pa.branchId,branch.branchLocation,pa.dateRecieve,pa.dateOfDelivery,pa.userId,usr.name ");
query.append("from com.ssms.models.repair.PendingAssign pa ,Model mdl,");
query.append("ProductCategory pc,Branch branch,");
query.append("User usr ");
query.append("where mdl.nextSequence = pa.modelId and pc.productCategoryId=mdl.productCategory and ");
query.append("mdl.productCategory=pa.productCategory and branch.actualBranchId = pa.branchId and ");
query.append("usr.userId = pa.userId and pa."+searchBy+"=:searchValue");



Model class remains the same ....

i have also googled but unfortunately i am still unable to find it what im doing wrong....


Top
 Profile  
 
 Post subject: Re: Reterving Data from database getting exception ...
PostPosted: Sun Feb 14, 2010 5:23 am 
Beginner
Beginner

Joined: Wed Nov 21, 2007 8:02 am
Posts: 48
I didn't check the api you are using. But looking at the exception you are getting in your initial post, if you use '= searchvalue' instead of '=:searchvalue' in your initial query, it will work


Top
 Profile  
 
 Post subject: Re: Reterving Data from database getting exception ...
PostPosted: Sun Feb 14, 2010 7:14 am 
Expert
Expert

Joined: Wed Mar 03, 2004 6:35 am
Posts: 1240
Location: Lund, Sweden
Since I don't know anything about your API it is hard to help you. In the last stacktrace there are no Hibernate classes involved, so maybe the problem is with how you use the getSelectiveDataFromDataStoredForDynamicQuery() method.


Top
 Profile  
 
 Post subject: Re: Reterving Data from database getting exception ...
PostPosted: Sun Feb 14, 2010 8:09 am 
Newbie

Joined: Sat Feb 13, 2010 1:04 pm
Posts: 10
nordborg,

this is my getSelectiveDataFromDataStoredForDynamicQuery Method :

public List getSelectiveDataFromDataStoredForDynamicQuery(String query, List<String>paramNames, List<Object> values) throws Exception{
List returnedList = new ArrayList();
try {
returnedList = getHibernateTemplate().findByNamedParam(query, getStringArray(paramNames), getObjectArray(values));
} catch (DataAccessException e) {
throw new Exception("Unable to get required data "+ e.getMessage());
}
return returnedList;
}


getStringArray Method:

private String[] getStringArray(List<String> paramNames) {
String[] retValues = new String[paramNames.size()];
for (int i = 0; i < paramNames.size(); i++) {
retValues[i] = paramNames.get(i);
}
return retValues;
}

getObject Array:

private Object[] getObjectArray(List<Object> values) {
Object[] retValues = new Object[values.size()];
for (int i = 0; i < values.size(); i++) {
retValues[i] = values.get(i);
}
return retValues;
}



inside that method i am using findByNamedParam from getHibernateTemplate.


Top
 Profile  
 
 Post subject: Re: Reterving Data from database getting exception ...
PostPosted: Tue Feb 16, 2010 11:31 am 
Newbie

Joined: Sat Feb 13, 2010 1:04 pm
Posts: 10
can any one help me it is urgent...........


Top
 Profile  
 
 Post subject: Re: Reterving Data from database getting exception ...
PostPosted: Tue Feb 16, 2010 3:17 pm 
Expert
Expert

Joined: Wed Mar 03, 2004 6:35 am
Posts: 1240
Location: Lund, Sweden
It may help if you can post the complete stack trace. Please change:

Code:
catch (DataAccessException e) {
throw new Exception("Unable to get required data "+ e.getMessage());
}

to
Code:
catch (DataAccessException e) {
throw new Exception("Unable to get required data "+ e.getMessage(), e);
}


What is getHibernateTemplate().findByNamedParam() supposed to do?


Top
 Profile  
 
 Post subject: Re: Reterving Data from database getting exception ...
PostPosted: Wed Feb 17, 2010 12:08 pm 
Newbie

Joined: Sat Feb 13, 2010 1:04 pm
Posts: 10
Hi nordborg ,

this is the full stack trace


org.springframework.orm.hibernate3.HibernateQueryException: could not locate named parameter [searchValue]; nested exception is org.hibernate.QueryParameterException: could not locate named parameter [searchValue]
at org.springframework.orm.hibernate3.SessionFactoryUtils.convertHibernateAccessException(SessionFactoryUtils.java:657)
at org.springframework.orm.hibernate3.HibernateAccessor.convertHibernateAccessException(HibernateAccessor.java:412)
at org.springframework.orm.hibernate3.HibernateTemplate.doExecute(HibernateTemplate.java:424)
at org.springframework.orm.hibernate3.HibernateTemplate.executeWithNativeSession(HibernateTemplate.java:374)
at org.springframework.orm.hibernate3.HibernateTemplate.findByNamedParam(HibernateTemplate.java:947)
at com.ssms.dao.common.HibernateExecutionTemplate.getSelectiveDataFromDataStoredForDynamicQuery(HibernateExecutionTemplate.java:126)
at com.ssms.dao.repair.PendingAssignDAOImpl.getPending(PendingAssignDAOImpl.java:41)
at com.ssms.services.repair.PendingAssignServiceImpl.getPending(PendingAssignServiceImpl.java:19)
at com.ssms.web.actions.repair.PendingAssignAction.execute(PendingAssignAction.java:21)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at com.opensymphony.xwork2.DefaultActionInvocation.invokeAction(DefaultActionInvocation.java:441)
at com.opensymphony.xwork2.DefaultActionInvocation.invokeActionOnly(DefaultActionInvocation.java:280)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:243)
at com.opensymphony.xwork2.interceptor.DefaultWorkflowInterceptor.doIntercept(DefaultWorkflowInterceptor.java:165)
at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
at com.opensymphony.xwork2.validator.ValidationInterceptor.doIntercept(ValidationInterceptor.java:252)
at org.apache.struts2.interceptor.validation.AnnotationValidationInterceptor.doIntercept(AnnotationValidationInterceptor.java:68)
at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
at com.opensymphony.xwork2.interceptor.ConversionErrorInterceptor.intercept(ConversionErrorInterceptor.java:122)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
at com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:195)
at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
at com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:195)
at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
at com.opensymphony.xwork2.interceptor.StaticParametersInterceptor.intercept(StaticParametersInterceptor.java:179)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
at org.apache.struts2.interceptor.MultiselectInterceptor.intercept(MultiselectInterceptor.java:75)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
at org.apache.struts2.interceptor.CheckboxInterceptor.intercept(CheckboxInterceptor.java:94)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
at org.apache.struts2.interceptor.FileUploadInterceptor.intercept(FileUploadInterceptor.java:235)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
at com.opensymphony.xwork2.interceptor.ModelDrivenInterceptor.intercept(ModelDrivenInterceptor.java:89)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
at com.opensymphony.xwork2.interceptor.ScopedModelDrivenInterceptor.intercept(ScopedModelDrivenInterceptor.java:130)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
at org.apache.struts2.interceptor.debugging.DebuggingInterceptor.intercept(DebuggingInterceptor.java:267)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
at com.opensymphony.xwork2.interceptor.ChainingInterceptor.intercept(ChainingInterceptor.java:126)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
at com.opensymphony.xwork2.interceptor.PrepareInterceptor.doIntercept(PrepareInterceptor.java:138)
at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
at com.opensymphony.xwork2.interceptor.I18nInterceptor.intercept(I18nInterceptor.java:165)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
at org.apache.struts2.interceptor.ServletConfigInterceptor.intercept(ServletConfigInterceptor.java:164)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
at com.opensymphony.xwork2.interceptor.AliasInterceptor.intercept(AliasInterceptor.java:179)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
at com.opensymphony.xwork2.interceptor.ExceptionMappingInterceptor.intercept(ExceptionMappingInterceptor.java:176)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
at org.apache.struts2.impl.StrutsActionProxy.execute(StrutsActionProxy.java:52)
at org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:488)
at org.apache.struts2.dispatcher.FilterDispatcher.doFilter(FilterDispatcher.java:395)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at com.ssms.web.actions.login.AuthorizationInterceptor.doFilterInternal(AuthorizationInterceptor.java:30)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:845)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
at java.lang.Thread.run(Unknown Source)
Caused by: org.hibernate.QueryParameterException: could not locate named parameter [searchValue]
at org.hibernate.engine.query.ParameterMetadata.getNamedParameterDescriptor(ParameterMetadata.java:99)
at org.hibernate.engine.query.ParameterMetadata.getNamedParameterExpectedType(ParameterMetadata.java:105)
at org.hibernate.impl.AbstractQueryImpl.determineType(AbstractQueryImpl.java:437)
at org.hibernate.impl.AbstractQueryImpl.setParameter(AbstractQueryImpl.java:407)
at org.springframework.orm.hibernate3.HibernateTemplate.applyNamedParameterToQuery(HibernateTemplate.java:1257)
at org.springframework.orm.hibernate3.HibernateTemplate$31.doInHibernate(HibernateTemplate.java:953)
at org.springframework.orm.hibernate3.HibernateTemplate.doExecute(HibernateTemplate.java:419)




getHibernateTemplate.findByNamedParam() is an spring API for hibernate + JPA


it is equal to
Query queryHQL = session.createQuery(query);
List lst = queryHQL.setParameter("searchValue", value).list();


Top
 Profile  
 
 Post subject: Re: Reterving Data from database getting exception ...
PostPosted: Wed Feb 17, 2010 2:36 pm 
Expert
Expert

Joined: Wed Mar 03, 2004 6:35 am
Posts: 1240
Location: Lund, Sweden
If everything is as written here in this thread I can't find out what is wrong. Is it possible for you to skip the spring part and just try the equivalent with Hibernate Session and Query objects directly. I think it is also time to enable some debugging. You can find instructions in the Hibernate documentation: http://docs.jboss.org/hibernate/stable/ ... on-logging

Enable debug-level logging for at least org.hibernate.SQL, org.hibernate.type and org.hibernate.hql.ast.AST.


Top
 Profile  
 
 Post subject: Re: Reterving Data from database getting exception ...
PostPosted: Fri Feb 19, 2010 2:02 pm 
Newbie

Joined: Sat Feb 13, 2010 1:04 pm
Posts: 10
hi nordborg ,

this is the strack trace i got


98469 [http-8080-1] DEBUG org.springframework.orm.hibernate3.SessionFactoryUtils - Opening Hibernate Session
98469 [http-8080-1] DEBUG org.hibernate.impl.SessionImpl - opened session at timestamp: 12666509842
98469 [http-8080-1] WARN org.hibernate.hql.QuerySplitter - no persistent classes found for query class: select pa.id,pa.serviceRecordNo,pa.modelId,mdl.serviceModelName,pa.productCategory,pc.prodCategoryName,pa.branchId,branch.branchLocation,pa.dateRecieve,pa.dateOfDelivery,pa.userId,usr.name from com.ssms.models.repair.PendingAssign pa ,Model mdl,ProductCategory pc,Branch branch,User usr where mdl.nextSequence = pa.modelId and pc.productCategoryId=mdl.productCategory and mdl.productCategory=pa.productCategory and branch.actualBranchId = pa.branchId and usr.userId = pa.userId and pa.serviceRecordNo=:searchValue
98484 [http-8080-1] DEBUG org.springframework.orm.hibernate3.SessionFactoryUtils - Closing Hibernate Session
98484 [http-8080-1] DEBUG com.ssms.dao.common.HibernateExecutionTemplate - inside getSelectiveDataFromDataStoredForDynamicQueryorg.springframework.orm.hibernate3.HibernateQueryException: could not locate named parameter [searchValue]; nested exception is org.hibernate.QueryParameterException: could not locate named parameter [searchValue]

i did not skip spring part .... after this also if u want me to skip spring and need to get it with hibernate session i will do it but i have to change the configuration file .......

waiting for your reply....


Top
 Profile  
 
 Post subject: Re: Reterving Data from database getting exception ...
PostPosted: Sat Feb 20, 2010 11:47 am 
Newbie

Joined: Sat Feb 13, 2010 1:04 pm
Posts: 10
Hi nordborg ,


i have disabled spring part this is the exception i got ...........


35766 [http-8080-1] INFO org.hibernate.tool.hbm2ddl.SchemaExport - exporting generated schema to database
35766 [http-8080-1] INFO org.hibernate.tool.hbm2ddl.SchemaExport - schema export complete
35766 [http-8080-1] DEBUG org.hibernate.impl.SessionFactoryImpl - Checking 0 named HQL queries
35766 [http-8080-1] DEBUG org.hibernate.impl.SessionFactoryImpl - Checking 0 named SQL queries
35766 [http-8080-1] DEBUG org.hibernate.impl.SessionImpl - opened session at timestamp: 12667292784
35766 [http-8080-1] WARN org.hibernate.hql.QuerySplitter - no persistent classes found for query class: select pa.id,pa.serviceRecordNo,pa.modelId,mdl.serviceModelName,pa.productCategory,pc.prodCategoryName,pa.branchId,branch.branchLocation,pa.dateRecieve,pa.dateOfDelivery,pa.userId,usr.name from com.ssms.models.repair.PendingAssign pa ,Model mdl,ProductCategory pc,Branch branch,User usr where mdl.nextSequence = pa.modelId and pc.productCategoryId=mdl.productCategory and mdl.productCategory=pa.productCategory and branch.actualBranchId = pa.branchId and usr.userId = pa.userId and pa.serviceRecordNo=:searchValue
35766 [http-8080-1] DEBUG com.ssms.dao.common.HibernateExecutionTemplate - org.hibernate.QueryParameterException: could not locate named parameter [searchValue]

if u could get me out of this exception it will be great ......,


Top
 Profile  
 
 Post subject: Re: Reterving Data from database getting exception ...
PostPosted: Sat Feb 20, 2010 2:03 pm 
Beginner
Beginner

Joined: Wed Nov 21, 2007 8:02 am
Posts: 48
I am relatively new to hibernate as well.
But I am eager to find out the reason behind your problem.

Quote:
from com.ssms.models.repair.PendingAssign pa ,Model mdl,ProductCategory pc,Branch branch,User usr


1)why do you provide full class name for the first and simple name for others?
2)what happens if you provide just the class name for all? or what happens if you provide the full class name for all.
3)Is any class (PendingAssign, Model, ProductCategory,Branch,User] is not directly mapped instead their subclasses are mapped?

By the way, the class that throws the your exception has the following comment.
//this is one of the ugliest and most fragile pieces of code in Hibernate....
so it might be a bug in hibernate


Top
 Profile  
 
 Post subject: Re: Reterving Data from database getting exception ...
PostPosted: Sat Feb 20, 2010 11:45 pm 
Newbie

Joined: Sat Feb 13, 2010 1:04 pm
Posts: 10
Hi kavithakaran,

Answer to your questions

1) if i did not give fully qualified name it says PendingAssign is not mapped. but i have mapped in xml file.
2) a)it give me exception saying PendingAssign is not mapped
b)if i provide full class name for all it throws above said exception

3)i have directly mapped this classes in xml ....


Top
 Profile  
 
 Post subject: Re: Reterving Data from database getting exception ...
PostPosted: Sun Feb 21, 2010 5:26 am 
Beginner
Beginner

Joined: Wed Nov 21, 2007 8:02 am
Posts: 48
It's strange. Regardless of the value of auto-import, providing fully qualified class names should work.

why don't you build query incremently to spot the problem?

1) 1st run
query.append("from PendingAssign pa");

2)2nd run
query.append("from PendingAssign pa ");
query.append("pa."+searchBy+"=:"+queryString);

3) query.append("from PendingAssign pa ,Model mdl");
query.append("where mdl.nextSequence = pa.modelId ");
query.append("pa."+searchBy+"=:"+queryString);


and so on.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 16 posts ]  Go to page 1, 2  Next

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.