I am also getting same problem while running in hibernate criteria editor.
while running the criteria query
session.createCriteria(Student.class)
.list()
the Hibernate Criteria Editor runs fine.
But as I add a restriction the hibernate criteria editor fails
session.createCriteria(Student.class)
.add(Restrictions.eq("studentId",1))
.list()
Error :
!ENTRY org.hibernate.eclipse.console 4 150 2015-12-17 14:44:25.181
!MESSAGE Exception while executing HQL Query
!SUBENTRY 1 org.hibernate.eclipse.console 4 150 2015-12-17 14:44:25.182
!MESSAGE Sourced file: inline evaluation of: `` session.createCriteria(Student.class) .add(Restrictions.eq("studentId",1)) . . . '' : Error in method invocation: Method add( org.hibernate.criterion.SimpleExpression ) not found in class'org.jboss.tools.hibernate.proxy.CriteriaProxy' : at Line: 3 : in file: inline evaluation of: `` session.createCriteria(Student.class) .add(Restrictions.eq("studentId",1)) . . . '' : .add ( Restrictions .eq ( "studentId" , 1 ) )
!STACK 0
Sourced file: inline evaluation of: `` session.createCriteria(Student.class) .add(Restrictions.eq("studentId",1)) . . . '' : Error in method invocation: Method add( org.hibernate.criterion.SimpleExpression ) not found in class'org.jboss.tools.hibernate.proxy.CriteriaProxy' : at Line: 3 : in file: inline evaluation of: `` session.createCriteria(Student.class) .add(Restrictions.eq("studentId",1)) . . . '' : .add ( Restrictions .eq ( "studentId" , 1 ) )
at bsh.BSHPrimarySuffix.doName(Unknown Source)
at bsh.BSHPrimarySuffix.doSuffix(Unknown Source)
at bsh.BSHPrimaryExpression.eval(Unknown Source)
at bsh.BSHPrimaryExpression.eval(Unknown Source)
at bsh.Interpreter.eval(Unknown Source)
at bsh.Interpreter.eval(Unknown Source)
at bsh.Interpreter.eval(Unknown Source)
at org.hibernate.eclipse.console.common.JavaPage.setSession(JavaPage.java:73)
at org.hibernate.eclipse.console.common.HibernateExtension$3.execute(HibernateExtension.java:127)
at org.hibernate.console.execution.DefaultExecutionContext.execute(DefaultExecutionContext.java:63)
at org.hibernate.eclipse.console.common.HibernateExtension.execute(HibernateExtension.java:189)
at org.hibernate.eclipse.console.common.HibernateExtension.executeCriteriaQuery(HibernateExtension.java:123)
at org.hibernate.console.ConsoleConfiguration.executeBSHQuery(ConsoleConfiguration.java:313)
at org.hibernate.eclipse.criteriaeditor.CriteriaEditor.executeQuery(CriteriaEditor.java:142)
at org.hibernate.eclipse.console.actions.ExecuteQueryAction.execute(ExecuteQueryAction.java:88)
at org.hibernate.eclipse.console.actions.ExecuteQueryAction.run(ExecuteQueryAction.java:56)
at org.eclipse.jface.action.Action.runWithEvent(Action.java:519)
at org.hibernate.eclipse.console.actions.ExecuteQueryAction.runWithEvent(ExecuteQueryAction.java:60)
at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection(ActionContributionItem.java:595)
at org.eclipse.jface.action.ActionContributionItem.access$2(ActionContributionItem.java:511)
at org.eclipse.jface.action.ActionContributionItem$6.handleEvent(ActionContributionItem.java:462)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
at org.eclipse.swt.widgets.Display.sendEvent(Display.java:4353)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1061)
at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:4172)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3761)
at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$9.run(PartRenderingEngine.java:1151)
at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:1032)
at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:148)
at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:636)
at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:579)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:150)
at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:135)
at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:134)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:104)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:380)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:235)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:648)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:603)
at org.eclipse.equinox.launcher.Main.run(Main.java:1465)
at org.eclipse.equinox.launcher.Main.main(Main.java:1438)
!SUBENTRY 2 org.hibernate.eclipse.console 4 150 2015-12-17 14:44:25.182
!MESSAGE Sourced file: inline evaluation of: `` session.createCriteria(Student.class) .add(Restrictions.eq("studentId",1)) . . . '' : Error in method invocation: Method add( org.hibernate.criterion.SimpleExpression ) not found in class'org.jboss.tools.hibernate.proxy.CriteriaProxy' : at Line: 3 : in file: inline evaluation of: `` session.createCriteria(Student.class) .add(Restrictions.eq("studentId",1)) . . . '' : .add ( Restrictions .eq ( "studentId" , 1 ) )
!STACK 0
Sourced file: inline evaluation of: `` session.createCriteria(Student.class) .add(Restrictions.eq("studentId",1)) . . . '' : Error in method invocation: Method add( org.hibernate.criterion.SimpleExpression ) not found in class'org.jboss.tools.hibernate.proxy.CriteriaProxy' : at Line: 3 : in file: inline evaluation of: `` session.createCriteria(Student.class) .add(Restrictions.eq("studentId",1)) . . . '' : .add ( Restrictions .eq ( "studentId" , 1 ) )
at bsh.BSHPrimarySuffix.doName(Unknown Source)
at bsh.BSHPrimarySuffix.doSuffix(Unknown Source)
at bsh.BSHPrimaryExpression.eval(Unknown Source)
at bsh.BSHPrimaryExpression.eval(Unknown Source)
at bsh.Interpreter.eval(Unknown Source)
at bsh.Interpreter.eval(Unknown Source)
at bsh.Interpreter.eval(Unknown Source)
at org.hibernate.eclipse.console.common.JavaPage.setSession(JavaPage.java:73)
at org.hibernate.eclipse.console.common.HibernateExtension$3.execute(HibernateExtension.java:127)
at org.hibernate.console.execution.DefaultExecutionContext.execute(DefaultExecutionContext.java:63)
at org.hibernate.eclipse.console.common.HibernateExtension.execute(HibernateExtension.java:189)
at org.hibernate.eclipse.console.common.HibernateExtension.executeCriteriaQuery(HibernateExtension.java:123)
at org.hibernate.console.ConsoleConfiguration.executeBSHQuery(ConsoleConfiguration.java:313)
at org.hibernate.eclipse.criteriaeditor.CriteriaEditor.executeQuery(CriteriaEditor.java:142)
at org.hibernate.eclipse.console.actions.ExecuteQueryAction.execute(ExecuteQueryAction.java:88)
at org.hibernate.eclipse.console.actions.ExecuteQueryAction.run(ExecuteQueryAction.java:56)
at org.eclipse.jface.action.Action.runWithEvent(Action.java:519)
at org.hibernate.eclipse.console.actions.ExecuteQueryAction.runWithEvent(ExecuteQueryAction.java:60)
at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection(ActionContributionItem.java:595)
at org.eclipse.jface.action.ActionContributionItem.access$2(ActionContributionItem.java:511)
at org.eclipse.jface.action.ActionContributionItem$6.handleEvent(ActionContributionItem.java:462)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
at org.eclipse.swt.widgets.Display.sendEvent(Display.java:4353)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1061)
at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:4172)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3761)
at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$9.run(PartRenderingEngine.java:1151)
at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:1032)
at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:148)
at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:636)
at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:579)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:150)
at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:135)
at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:134)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:104)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:380)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:235)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:648)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:603)
at org.eclipse.equinox.launcher.Main.run(Main.java:1465)
at org.eclipse.equinox.launcher.Main.main(Main.java:1438)
Student.hbm.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class name="org.maven.hibernate.xml.std.v3.test.dto.xml.Student" table="STUDENT" catalog="test1">
<id name="studentId" type="int">
<column name="STUDENT_ID"/>
<generator class="increment"/>
</id>
<property name="studentName" type="java.lang.String">
<column name="STUDENT_NAME" not-null="true"/>
</property>
</class>
</hibernate-mapping>
Student.java
public class Student implements java.io.Serializable {
private int studentId;
private String studentName;
public Student() {
}
public Student(int studentId, String studentName) {
this.studentId = studentId;
this.studentName = studentName;
}
public int getStudentId() {
return this.studentId;
}
public void setStudentId(int studentId) {
this.studentId = studentId;
}
public String getStudentName() {
return this.studentName;
}
public void setStudentName(String studentName) {
this.studentName = studentName;
}
}