Hi everybody ,
I am new to hibernate
I am using eclipse ,Mysql and hibernate 3.2.3
I have a simple application to save and load from sql.
I have department class
public class Department <
private int id;
private String name;
public Department(String name) <
this.name=name;
>
public int getId() <
return id;
>
public void setId(int id) <
this.id = id;
>
public String getName() <
return name;
>
public void setName(String name) <
this.name = name;
>
>
and here is the mapping file
and here comes the problem ,when i run this code
SessionFactory sessionFactory = new Configuration().configure().buildSessionFactory();
Session newSession = sessionFactory.openSession();
Transaction newTransaction = newSession.beginTransaction();
Query query=newSession.createQuery(«from Department as dept order by dept.id asc»);
Iterator iter =query.iterate();
if(iter.hasNext())deptVector=new Vector();
while ( iter.hasNext() ) <
Department dep = (Department) iter.next(); //here is the error
//deptVector.add(dep);
>
when i reach this line i get this error
INFO: Error performing load command
org.hibernate.HibernateException: Javassist Enhancement failed: helper.Department
at org.hibernate.proxy.pojo.javassist.JavassistLazyInitializer.getProxy(JavassistLazyInitializer.java:142)
at org.hibernate.proxy.pojo.javassist.JavassistProxyFactory.getProxy(JavassistProxyFactory.java:72)
at org.hibernate.tuple.entity.AbstractEntityTuplizer.createProxy(AbstractEntityTuplizer.java:402)
at org.hibernate.persister.entity.AbstractEntityPersister.createProxy(AbstractEntityPersister.java:3483)
at org.hibernate.event.def.DefaultLoadEventListener.createProxyIfNecessary(DefaultLoadEventListener.java:298)
at org.hibernate.event.def.DefaultLoadEventListener.proxyOrLoad(DefaultLoadEventListener.java:219)
at org.hibernate.event.def.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:126)
at org.hibernate.impl.SessionImpl.fireLoad(SessionImpl.java:905)
at org.hibernate.impl.SessionImpl.internalLoad(SessionImpl.java:873)
at org.hibernate.type.EntityType.resolveIdentifier(EntityType.java:590)
at org.hibernate.type.EntityType.resolve(EntityType.java:412)
at org.hibernate.type.EntityType.nullSafeGet(EntityType.java:227)
at org.hibernate.impl.IteratorImpl.next(IteratorImpl.java:135)
at main.GetAllDepartmentsServlet.doGet(GetAllDepartmentsServlet.java:37)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:627)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:269)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:172)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:108)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:174)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:875)
at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:665)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:528)
at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:81)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:689)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.InstantiationException: helper.Department_$$_javassist_0
at java.lang.Class.newInstance0(Unknown Source)
at java.lang.Class.newInstance(Unknown Source)
at org.hibernate.proxy.pojo.javassist.JavassistLazyInitializer.getProxy(JavassistLazyInitializer.java:139)
. 29 more
any ideas please??
i even do not know what is javassit??
Источник
Hibernate Error Performing Load Command
We have collected for you the most relevant information on Hibernate Error Performing Load Command, as well as possible solutions to this problem. Take a look at the links provided and find the solution that works. Other people have encountered Hibernate Error Performing Load Command before you, so use the ready-made solutions.
java — Error performing load command : org.hibernate .
- https://stackoverflow.com/questions/24222835/error-performing-load-command-org-hibernate-exception-sqlgrammarexception-cou
- I’m trying to set up a small working sample of JPA, however when I run the code I get the follwing error: import javax.persistence.EntityManager; import javax.persistence.EntityManagerFactory; imp.
HHH000327: Error performing load command : org.hibernate .
- https://stackoverflow.com/questions/62162568/hhh000327-error-performing-load-command-org-hibernate-exception-genericjdbcex
- I am using JPA2.2 with Hibernate and a MySql database. I have a simple Entity (Account) and when I try to send a simple query, I get a hibernate Exception and crashes because it goes out of memory. Any help in tracking this issue will be great.
Hibernate Community • View topic — Error performing load .
- https://forum.hibernate.org/viewtopic.php?p=2405448
- May 19, 2010 · Hi everybody , I am new to hibernate I am using eclipse ,Mysql and hibernate 3.2.3 I have a simple application to save and load from sql. I have department class
Error performing load command: org.hibernate.ex. JBoss .
- https://developer.jboss.org/thread/271927
- Aug 16, 2016 · Hi Dev, In JBoss have found an exception which relates to JDBC Exception. Only in production environment can we reproduce this error not in development.
java — Error performing load command : org.hibernate .
- https://pt.stackoverflow.com/questions/316373/error-performing-load-command-org-hibernate-objectnotfoundexception-no-row-wi
- Consegui resolver apenas apagando a tabela do meu Banco de dados Mysql e deixando o hibernate regerar novamente ao iniciar a aplicação. compartilhar melhorar esta resposta
How to hibernate Windows from command line
- https://www.windows-commandline.com/hibernate-windows/
- We can hibernate a Windows computer from command prompt using shutdown command. Shutdown command has various switches for different operations like shutdown, reboot, hibernate, log off etc. The command for hibernating windows computer is given below. shutdown /h. This works on all Windows versions – XP, Vista, Windows 7, Server 2003 and .
org.hibernate.exception.SQLGrammarException: could not .
- https://stackoverflow.com/questions/34446364/org-hibernate-exception-sqlgrammarexception-could-not-extract-resultset
- Teams. Q&A for Work. Stack Overflow for Teams is a private, secure spot for you and your coworkers to find and share information.
java — Error performing load command : org.hibernate .
- http://www.itgo.me/a/x6204484295650534293/error-performing-load-command-org-hibernate-exception-sqlgrammarexception-cou
- 2020и…ѕи®Їдє‘е…±еђЊж€вЂњз–«вЂќпјЊеЉ©еЉ›е¤Ќе·Ґпј€дјжѓ е‰Ќж‰ЂжњЄжњ‰пјЃ4ж ё8G,5Mеё¦е®Ѕ 1684е…ѓ/3年), ењ°еќЂпјљhttps://cloud.tencent.com/act/cps/redirect?redirect .
Issue with unidirectional one-to-many association with a .
- https://github.com/hibernate/hibernate-orm/issues/1786
- P.S. like @vladmihalcea said we’d love a patch which applies directly on the latest version of master, but if you’re not familiar with git and/or github we can help of course! Let us know if you need some guidance, or if you prefer someone from the team could try extracting your patch. Alternatively you can also attach a traditional patch file to a JIRA ticket.
AppSync: Mount copy phase failed with «VMAX operation .
- https://www.dell.com/support/kbdoc/en-us/000174090/appsync-mount-copy-phase-failed-with-vmax-operation-failed-error-exception-thrown-while-linking-the-copy-org-hibernate-exception-genericjdbcexception-could-not-extract-resultset
- Service Plan is failing in mount phase while running an internal query to get the VMAX device details and copy details for linking. For the specific issue this article addresses, the following query will be seen in server logs just before the issue:
Hibernate Error Performing Load Command Fixes & Solutions
We are confident that the above descriptions of Hibernate Error Performing Load Command and how to fix it will be useful to you. If you have another solution to Hibernate Error Performing Load Command or some notes on the existing ways to solve it, then please drop us an email.
Источник
Hibernate error performing load command
EDIT: See post #2 for the cause of the problem.
Since migrating from Glassfish to Wildfly (and thus Hibernate 4.2.3 to 4.3.1) I am experiencing an issue that wasn’t present before the migration. When a particular named query gets executed, sometimes we get an exception, other times it works fine. The query in question is:
SELECT ase FROM AgentStateEntity ase WHERE (ase.agent = :agent OR ase.agent IS NULL) AND ase.pbxEvent.eventTime >= :date ORDER BY ase.pbxEvent DESC
A snippet of the enormous stack trace is:
HHH000327: Error performing load command : org.hibernate.exception.SQLGrammarException: could not extract ResultSet
Caused by: javax.persistence.PersistenceException: org.hibernate.exception.SQLGrammarException: could not extract ResultSet
Caused by: org.hibernate.exception.SQLGrammarException: could not extract ResultSet
Caused by: com.microsoft.sqlserver.jdbc.SQLServerException: Invalid column name ‘primarykey’.
By debugging, I verified that the values for the :agent and :date are valid so the query should execute without problem. It was and still is working on GF with Hibernate 4.2.3. The jdbc driver is the same and most recent for SQL Server 2008.
Here are the important parts of the entities that are involved in the query.
@MappedSuperclass
public abstract class ResourceStateEntity implements Serializable, IResourceState, IDTO
<
@ManyToOne
@JoinColumn(name = «pbxeventforeignkey», nullable = false, insertable = true, updatable = false)
private PbxEventEntity pbxEvent;
>
@NamedQuery(name = «AgentStateEntity.getCurrentState», query = «SELECT ase FROM AgentStateEntity ase WHERE (ase.agent = :agent OR ase.agent IS NULL) AND ase.pbxEvent.eventTime >= :date ORDER BY ase.pbxEvent DESC»))
@Entity
@Table(name = «dbo.agentstates»)
public class AgentStateEntity extends ResourceStateEntity implements Serializable, IAgentState
<
@Id
@Column(name = «primarykey», nullable = false, insertable = true, updatable = false)
private long primaryKey;
@ManyToOne
@JoinColumn(name = «agentforeignkey», nullable = true, insertable = true, updatable = false)
private AgentEntity agent = null;
>
@Entity
@Table(name = «dbo.pbxevents»)
public class PbxEventEntity implements IPbxEvent, Serializable, IDTO
<
private static final long serialVersionUID = 1L;
@Id
@Column(name = «primarykey», nullable = false)
private long primaryKey = 0L;
@Temporal(TemporalType.TIMESTAMP)
@Column(name = «eventtime», nullable = false)
private Calendar eventTime = null;
>
@Entity
@DiscriminatorValue(«1»)
public class AgentEntity extends PbxResourceEntity implements IAgent
<
//primarykey in base class
>
@Entity
@Table(name = «dbo.pbxresources»)
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
@DiscriminatorColumn(name = «type», discriminatorType = DiscriminatorType.INTEGER)
public class PbxResourceEntity implements IResource, Identifiable, Serializable
<
@Id
@GeneratedValue(strategy=GenerationType.IDENTITY)
@Column(name = «primarykey», nullable = false, insertable = true, updatable = false)
private int primaryKey = 0;
>
Last edited by Cain05 on Wed Feb 26, 2014 3:38 pm, edited 1 time in total.
We have Spring Boot application using a OneToOne annotation and PostgreSQL.
Owning class:
@Table(name = "PAYMENT")
public class PaymentDO {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "PAYMENT_ID", insertable = false, updatable = false, nullable = false)
private Long paymentId;
@OneToOne(mappedBy = "payment", fetch = FetchType.LAZY, cascade = CascadeType.ALL, orphanRemoval = true)
private PaymentBatchJobDO paymentBatchJob;
}
Owned class:
@Table(name = "PAYMENT_BATCH_JOB")
public class PaymentBatchJobDO {
@Id
@Column(name="PAYMENT_ID", updatable = false, nullable = false)
private Long paymentId;
@OneToOne
@PrimaryKeyJoinColumn(name = "PAYMENT_ID", referencedColumnName = "PAYMENT_ID")
private PaymentDO payment;
}
Until Spring Boot 2.1.12 is worked perfecty but with 2.2.0+ I get following error:
2020-02-14 11:08:20.631 INFO 67291 --- [ main] o.h.e.t.j.p.i.JtaPlatformInitiator : HHH000490: Using JtaPlatform implementation: [org.hibernate.engine.transaction.jta.platform.internal.NoJtaPlatform]
2020-02-14 11:08:20.636 INFO 67291 --- [ main] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default'
Payment onlyPaymentDO{paymentId=1945, paymentBatchJob=null, amountTotal=12.00}
PaymentPaymentDO{paymentId=1945, paymentBatchJob=null, amountTotal=12.00}
2020-02-14 11:08:21.108 ERROR 67291 --- [ main] org.hibernate.AssertionFailure : HHH000099: an assertion failure occurred (this may indicate a bug in Hibernate, but is more likely due to unsafe use of the session): org.hibernate.AssertionFailure: null identifier
org.hibernate.AssertionFailure: null identifier
at org.hibernate.engine.spi.EntityKey.<init>(EntityKey.java:51) ~[hibernate-core-5.4.6.Final.jar:5.4.6.Final]
at org.hibernate.internal.AbstractSharedSessionContract.generateEntityKey(AbstractSharedSessionContract.java:523) ~[hibernate-core-5.4.6.Final.jar:5.4.6.Final]
at org.hibernate.type.OneToOneType.isNull(OneToOneType.java:105) ~[hibernate-core-5.4.6.Final.jar:5.4.6.Final]
at org.hibernate.type.EntityType.resolve(EntityType.java:462) ~[hibernate-core-5.4.6.Final.jar:5.4.6.Final]
at org.hibernate.type.EntityType.resolve(EntityType.java:457) ~[hibernate-core-5.4.6.Final.jar:5.4.6.Final]
at org.hibernate.type.EntityType.replace(EntityType.java:358) ~[hibernate-core-5.4.6.Final.jar:5.4.6.Final]
at org.hibernate.type.AbstractType.replace(AbstractType.java:164) ~[hibernate-core-5.4.6.Final.jar:5.4.6.Final]
at org.hibernate.type.TypeHelper.replace(TypeHelper.java:204) ~[hibernate-core-5.4.6.Final.jar:5.4.6.Final]
at org.hibernate.event.internal.DefaultMergeEventListener.copyValues(DefaultMergeEventListener.java:488) ~[hibernate-core-5.4.6.Final.jar:5.4.6.Final]
at org.hibernate.event.internal.DefaultMergeEventListener.entityIsTransient(DefaultMergeEventListener.java:241) ~[hibernate-core-5.4.6.Final.jar:5.4.6.Final]
at org.hibernate.event.internal.DefaultMergeEventListener.entityIsDetached(DefaultMergeEventListener.java:318) ~[hibernate-core-5.4.6.Final.jar:5.4.6.Final]
at org.hibernate.event.internal.DefaultMergeEventListener.onMerge(DefaultMergeEventListener.java:172) ~[hibernate-core-5.4.6.Final.jar:5.4.6.Final]
at org.hibernate.event.internal.DefaultMergeEventListener.onMerge(DefaultMergeEventListener.java:70) ~[hibernate-core-5.4.6.Final.jar:5.4.6.Final]
at org.hibernate.event.service.internal.EventListenerGroupImpl.fireEventOnEachListener(EventListenerGroupImpl.java:108) ~[hibernate-core-5.4.6.Final.jar:5.4.6.Final]
at org.hibernate.internal.SessionImpl.fireMerge(SessionImpl.java:776) ~[hibernate-core-5.4.6.Final.jar:5.4.6.Final]
at org.hibernate.internal.SessionImpl.merge(SessionImpl.java:763) ~[hibernate-core-5.4.6.Final.jar:5.4.6.Final]
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:na]
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:na]
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:na]
at java.base/java.lang.reflect.Method.invoke(Method.java:566) ~[na:na]
at org.springframework.orm.jpa.SharedEntityManagerCreator$SharedEntityManagerInvocationHandler.invoke(SharedEntityManagerCreator.java:314) ~[spring-orm-5.2.0.RELEASE.jar:5.2.0.RELEASE]
at com.sun.proxy.$Proxy73.merge(Unknown Source) ~[na:na]
at org.springframework.data.jpa.repository.support.SimpleJpaRepository.save(SimpleJpaRepository.java:557) ~[spring-data-jpa-2.2.0.RELEASE.jar:2.2.0.RELEASE]
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:na]
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:na]
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:na]
at java.base/java.lang.reflect.Method.invoke(Method.java:566) ~[na:na]
at org.springframework.data.repository.core.support.RepositoryComposition$RepositoryFragments.invoke(RepositoryComposition.java:371) ~[spring-data-commons-2.2.0.RELEASE.jar:2.2.0.RELEASE]
at org.springframework.data.repository.core.support.RepositoryComposition.invoke(RepositoryComposition.java:204) ~[spring-data-commons-2.2.0.RELEASE.jar:2.2.0.RELEASE]
at org.springframework.data.repository.core.support.RepositoryFactorySupport$ImplementationMethodExecutionInterceptor.invoke(RepositoryFactorySupport.java:657) ~[spring-data-commons-2.2.0.RELEASE.jar:2.2.0.RELEASE]
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) ~[spring-aop-5.2.0.RELEASE.jar:5.2.0.RELEASE]
at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.doInvoke(RepositoryFactorySupport.java:621) ~[spring-data-commons-2.2.0.RELEASE.jar:2.2.0.RELEASE]
at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.invoke(RepositoryFactorySupport.java:605) ~[spring-data-commons-2.2.0.RELEASE.jar:2.2.0.RELEASE]
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) ~[spring-aop-5.2.0.RELEASE.jar:5.2.0.RELEASE]
at org.springframework.data.projection.DefaultMethodInvokingMethodInterceptor.invoke(DefaultMethodInvokingMethodInterceptor.java:80) ~[spring-data-commons-2.2.0.RELEASE.jar:2.2.0.RELEASE]
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) ~[spring-aop-5.2.0.RELEASE.jar:5.2.0.RELEASE]
at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:353) ~[spring-tx-5.2.0.RELEASE.jar:5.2.0.RELEASE]
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:99) ~[spring-tx-5.2.0.RELEASE.jar:5.2.0.RELEASE]
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) ~[spring-aop-5.2.0.RELEASE.jar:5.2.0.RELEASE]
at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:139) ~[spring-tx-5.2.0.RELEASE.jar:5.2.0.RELEASE]
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) ~[spring-aop-5.2.0.RELEASE.jar:5.2.0.RELEASE]
at org.springframework.data.jpa.repository.support.CrudMethodMetadataPostProcessor$CrudMethodMetadataPopulatingMethodInterceptor.invoke(CrudMethodMetadataPostProcessor.java:178) ~[spring-data-jpa-2.2.0.RELEASE.jar:2.2.0.RELEASE]
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) ~[spring-aop-5.2.0.RELEASE.jar:5.2.0.RELEASE]
at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:93) ~[spring-aop-5.2.0.RELEASE.jar:5.2.0.RELEASE]
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) ~[spring-aop-5.2.0.RELEASE.jar:5.2.0.RELEASE]
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:212) ~[spring-aop-5.2.0.RELEASE.jar:5.2.0.RELEASE]
at com.sun.proxy.$Proxy86.save(Unknown Source) ~[na:na]
at com.swisscom.billing.testhibernate.PaymentsTxService.addPaymentBatchJob(PaymentsTxService.java:53) ~[main/:na]
at com.swisscom.billing.testhibernate.PaymentsTxService$$FastClassBySpringCGLIB$$4919717e.invoke(<generated>) ~[main/:na]
at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218) ~[spring-core-5.2.0.RELEASE.jar:5.2.0.RELEASE]
at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:769) ~[spring-aop-5.2.0.RELEASE.jar:5.2.0.RELEASE]
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163) ~[spring-aop-5.2.0.RELEASE.jar:5.2.0.RELEASE]
at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:747) ~[spring-aop-5.2.0.RELEASE.jar:5.2.0.RELEASE]
at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:353) ~[spring-tx-5.2.0.RELEASE.jar:5.2.0.RELEASE]
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:99) ~[spring-tx-5.2.0.RELEASE.jar:5.2.0.RELEASE]
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) ~[spring-aop-5.2.0.RELEASE.jar:5.2.0.RELEASE]
at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:747) ~[spring-aop-5.2.0.RELEASE.jar:5.2.0.RELEASE]
at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:689) ~[spring-aop-5.2.0.RELEASE.jar:5.2.0.RELEASE]
at com.swisscom.billing.testhibernate.PaymentsTxService$$EnhancerBySpringCGLIB$$604ba717.addPaymentBatchJob(<generated>) ~[main/:na]
at com.swisscom.billing.testhibernate.StartupBean.onApplicationEvent(StartupBean.java:35) ~[main/:na]
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:na]
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:na]
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:na]
at java.base/java.lang.reflect.Method.invoke(Method.java:566) ~[na:na]
If I use a H2 database the error does not occur.
Configuration:
spring.jpa.hibernate.naming.physical-strategy=org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl
spring.jpa.database-platform=org.hibernate.dialect.PostgreSQL95Dialect
There are different ways to implement a OneToOne relationship. If I change to the (more typical) was:
Owned class:
@MapsId
private PaymentDO payment;
I get following error:
2020-02-14 11:25:41.048 ERROR 74847 --- [ main] o.h.engine.jdbc.spi.SqlExceptionHelper : ERROR: column paymentbat0_.payment_payment_id does not exist
Position: 8
2020-02-14 11:25:41.054 INFO 74847 --- [ main] o.h.e.internal.DefaultLoadEventListener : HHH000327: Error performing load command : org.hibernate.exception.SQLGrammarException: could not extract ResultSet
org.hibernate.exception.SQLGrammarException: could not extract ResultSet
at org.hibernate.exception.internal.SQLStateConversionDelegate.convert(SQLStateConversionDelegate.java:103) ~[hibernate-core-5.4.6.Final.jar:5.4.6.Final]
at org.hibernate.exception.internal.StandardSQLExceptionConverter.convert(StandardSQLExceptionConverter.java:42) ~[hibernate-core-5.4.6.Final.jar:5.4.6.Final]
at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:113) ~[hibernate-core-5.4.6.Final.jar:5.4.6.Final]
at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:99) ~[hibernate-core-5.4.6.Final.jar:5.4.6.Final]
at org.hibernate.engine.jdbc.internal.ResultSetReturnImpl.extract(ResultSetReturnImpl.java:67) ~[hibernate-core-5.4.6.Final.jar:5.4.6.Final]
at org.hibernate.loader.Loader.getResultSet(Loader.java:2287) ~[hibernate-core-5.4.6.Final.jar:5.4.6.Final]
at org.hibernate.loader.Loader.executeQueryStatement(Loader.java:2045) ~[hibernate-core-5.4.6.Final.jar:5.4.6.Final]
at org.hibernate.loader.Loader.executeQueryStatement(Loader.java:2007) ~[hibernate-core-5.4.6.Final.jar:5.4.6.Final]
at org.hibernate.loader.Loader.doQuery(Loader.java:953) ~[hibernate-core-5.4.6.Final.jar:5.4.6.Final]
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:354) ~[hibernate-core-5.4.6.Final.jar:5.4.6.Final]
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:324) ~[hibernate-core-5.4.6.Final.jar:5.4.6.Final]
at org.hibernate.loader.Loader.loadEntity(Loader.java:2401) ~[hibernate-core-5.4.6.Final.jar:5.4.6.Final]
at org.hibernate.loader.entity.AbstractEntityLoader.load(AbstractEntityLoader.java:64) ~[hibernate-core-5.4.6.Final.jar:5.4.6.Final]
at org.hibernate.loader.entity.EntityLoader.loadByUniqueKey(EntityLoader.java:144) ~[hibernate-core-5.4.6.Final.jar:5.4.6.Final]
at org.hibernate.persister.entity.AbstractEntityPersister.loadByUniqueKey(AbstractEntityPersister.java:2384) ~[hibernate-core-5.4.6.Final.jar:5.4.6.Final]
at org.hibernate.type.EntityType.loadByUniqueKey(EntityType.java:745) ~[hibernate-core-5.4.6.Final.jar:5.4.6.Final]
at org.hibernate.type.EntityType.resolve(EntityType.java:467) ~[hibernate-core-5.4.6.Final.jar:5.4.6.Final]
at org.hibernate.engine.internal.TwoPhaseLoad.doInitializeEntity(TwoPhaseLoad.java:226) ~[hibernate-core-5.4.6.Final.jar:5.4.6.Final]
at org.hibernate.engine.internal.TwoPhaseLoad.initializeEntity(TwoPhaseLoad.java:160) ~[hibernate-core-5.4.6.Final.jar:5.4.6.Final]
at org.hibernate.loader.plan.exec.process.internal.AbstractRowReader.performTwoPhaseLoad(AbstractRowReader.java:255) ~[hibernate-core-5.4.6.Final.jar:5.4.6.Final]
at org.hibernate.loader.plan.exec.process.internal.AbstractRowReader.finishUp(AbstractRowReader.java:215) ~[hibernate-core-5.4.6.Final.jar:5.4.6.Final]
at org.hibernate.loader.plan.exec.process.internal.ResultSetProcessorImpl.extractResults(ResultSetProcessorImpl.java:141) ~[hibernate-core-5.4.6.Final.jar:5.4.6.Final]
at org.hibernate.loader.plan.exec.internal.AbstractLoadPlanBasedLoader.executeLoad(AbstractLoadPlanBasedLoader.java:105) ~[hibernate-core-5.4.6.Final.jar:5.4.6.Final]
at org.hibernate.loader.entity.plan.AbstractLoadPlanBasedEntityLoader.load(AbstractLoadPlanBasedEntityLoader.java:197) ~[hibernate-core-5.4.6.Final.jar:5.4.6.Final]
at org.hibernate.persister.entity.AbstractEntityPersister.load(AbstractEntityPersister.java:4350) ~[hibernate-core-5.4.6.Final.jar:5.4.6.Final]
at org.hibernate.event.internal.DefaultLoadEventListener.loadFromDatasource(DefaultLoadEventListener.java:570) ~[hibernate-core-5.4.6.Final.jar:5.4.6.Final]
at org.hibernate.event.internal.DefaultLoadEventListener.doLoad(DefaultLoadEventListener.java:538) ~[hibernate-core-5.4.6.Final.jar:5.4.6.Final]
at org.hibernate.event.internal.DefaultLoadEventListener.load(DefaultLoadEventListener.java:208) ~[hibernate-core-5.4.6.Final.jar:5.4.6.Final]
at org.hibernate.event.internal.DefaultLoadEventListener.proxyOrLoad(DefaultLoadEventListener.java:333) ~[hibernate-core-5.4.6.Final.jar:5.4.6.Final]
at org.hibernate.event.internal.DefaultLoadEventListener.doOnLoad(DefaultLoadEventListener.java:108) ~[hibernate-core-5.4.6.Final.jar:5.4.6.Final]
at org.hibernate.event.internal.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:74) ~[hibernate-core-5.4.6.Final.jar:5.4.6.Final]
at org.hibernate.event.service.internal.EventListenerGroupImpl.fireEventOnEachListener(EventListenerGroupImpl.java:118) ~[hibernate-core-5.4.6.Final.jar:5.4.6.Final]
at org.hibernate.internal.SessionImpl.fireLoadNoChecks(SessionImpl.java:1182) ~[hibernate-core-5.4.6.Final.jar:5.4.6.Final]
at org.hibernate.internal.SessionImpl.fireLoad(SessionImpl.java:1171) ~[hibernate-core-5.4.6.Final.jar:5.4.6.Final]
at org.hibernate.internal.SessionImpl.access$2000(SessionImpl.java:198) ~[hibernate-core-5.4.6.Final.jar:5.4.6.Final]
at org.hibernate.internal.SessionImpl$IdentifierLoadAccessImpl.doLoad(SessionImpl.java:2809) ~[hibernate-core-5.4.6.Final.jar:5.4.6.Final]
at org.hibernate.internal.SessionImpl$IdentifierLoadAccessImpl.lambda$load$1(SessionImpl.java:2790) ~[hibernate-core-5.4.6.Final.jar:5.4.6.Final]
at org.hibernate.internal.SessionImpl$IdentifierLoadAccessImpl.perform(SessionImpl.java:2746) ~[hibernate-core-5.4.6.Final.jar:5.4.6.Final]
at org.hibernate.internal.SessionImpl$IdentifierLoadAccessImpl.load(SessionImpl.java:2790) ~[hibernate-core-5.4.6.Final.jar:5.4.6.Final]
at org.hibernate.internal.SessionImpl.find(SessionImpl.java:3340) ~[hibernate-core-5.4.6.Final.jar:5.4.6.Final]
at org.hibernate.internal.SessionImpl.find(SessionImpl.java:3312) ~[hibernate-core-5.4.6.Final.jar:5.4.6.Final]
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:na]
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:na]
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:na]
at java.base/java.lang.reflect.Method.invoke(Method.java:566) ~[na:na]
at org.springframework.orm.jpa.SharedEntityManagerCreator$SharedEntityManagerInvocationHandler.invoke(SharedEntityManagerCreator.java:314) ~[spring-orm-5.2.0.RELEASE.jar:5.2.0.RELEASE]
at com.sun.proxy.$Proxy74.find(Unknown Source) ~[na:na]
at org.springframework.data.jpa.repository.support.SimpleJpaRepository.findById(SimpleJpaRepository.java:281) ~[spring-data-jpa-2.2.0.RELEASE.jar:2.2.0.RELEASE]
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:na]
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:na]
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:na]
at java.base/java.lang.reflect.Method.invoke(Method.java:566) ~[na:na]
at org.springframework.data.repository.core.support.RepositoryComposition$RepositoryFragments.invoke(RepositoryComposition.java:371) ~[spring-data-commons-2.2.0.RELEASE.jar:2.2.0.RELEASE]
at org.springframework.data.repository.core.support.RepositoryComposition.invoke(RepositoryComposition.java:204) ~[spring-data-commons-2.2.0.RELEASE.jar:2.2.0.RELEASE]
at org.springframework.data.repository.core.support.RepositoryFactorySupport$ImplementationMethodExecutionInterceptor.invoke(RepositoryFactorySupport.java:657) ~[spring-data-commons-2.2.0.RELEASE.jar:2.2.0.RELEASE]
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) ~[spring-aop-5.2.0.RELEASE.jar:5.2.0.RELEASE]
at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.doInvoke(RepositoryFactorySupport.java:621) ~[spring-data-commons-2.2.0.RELEASE.jar:2.2.0.RELEASE]
at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.invoke(RepositoryFactorySupport.java:605) ~[spring-data-commons-2.2.0.RELEASE.jar:2.2.0.RELEASE]
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) ~[spring-aop-5.2.0.RELEASE.jar:5.2.0.RELEASE]
at org.springframework.data.projection.DefaultMethodInvokingMethodInterceptor.invoke(DefaultMethodInvokingMethodInterceptor.java:80) ~[spring-data-commons-2.2.0.RELEASE.jar:2.2.0.RELEASE]
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) ~[spring-aop-5.2.0.RELEASE.jar:5.2.0.RELEASE]
at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:353) ~[spring-tx-5.2.0.RELEASE.jar:5.2.0.RELEASE]
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:99) ~[spring-tx-5.2.0.RELEASE.jar:5.2.0.RELEASE]
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) ~[spring-aop-5.2.0.RELEASE.jar:5.2.0.RELEASE]
at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:139) ~[spring-tx-5.2.0.RELEASE.jar:5.2.0.RELEASE]
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) ~[spring-aop-5.2.0.RELEASE.jar:5.2.0.RELEASE]
at org.springframework.data.jpa.repository.support.CrudMethodMetadataPostProcessor$CrudMethodMetadataPopulatingMethodInterceptor.invoke(CrudMethodMetadataPostProcessor.java:178) ~[spring-data-jpa-2.2.0.RELEASE.jar:2.2.0.RELEASE]
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) ~[spring-aop-5.2.0.RELEASE.jar:5.2.0.RELEASE]
at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:93) ~[spring-aop-5.2.0.RELEASE.jar:5.2.0.RELEASE]
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) ~[spring-aop-5.2.0.RELEASE.jar:5.2.0.RELEASE]
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:212) ~[spring-aop-5.2.0.RELEASE.jar:5.2.0.RELEASE]
at com.sun.proxy.$Proxy83.findById(Unknown Source) ~[na:na]
at com.swisscom.billing.testhibernate.StartupBean.onApplicationEvent(StartupBean.java:28) ~[main/:na]
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:na]
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:na]
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:na]
at java.base/java.lang.reflect.Method.invoke(Method.java:566) ~[na:na]
—> paymentbat0_.payment_payment_id does not exist!
Two problems — If I query an entity, I get…
ERROR: ORA-00933: SQL command not properly ended
Nov 11, 2013 8:47:36 PM org.hibernate.event.internal.DefaultLoadEventListener onLoad
INFO: HHH000327: Error performing load command : org.hibernate.exception.SQLGrammarException: could not extract ResultSet
If I try to insert an entity, I get…
Hibernate: insert into MyDB.dbo.BOSS_CONTACTS_C_LVL (CNTCT_PHN_NBR, CVM_CNTCT_EMAIL, DTID, BUSINESS_NAME, CONTACT_NAME, FIRST_NAME, LAST_NAME, PHONE_NUMBER, CONTACT_TITLE, EMPLOYEES_HERE, REGION, AREA, BRANCH_NAME, BRANCH_ID, IN_OUTBOUND, PROSPECT_TYPE, RATING, DUNS_NUMBER, ADDRESS, CITY, STATE, ZIP, LOCAL_STREET, LOCAL_CITY, LOCAL_STATE_PROVINCE, LOCAL_ZIP_POSTAL_CODE, HANDSET_POTENTIAL, CAMPAIGN_NAME, CAMPAIGN_CODE, ASSIGNED_REP, TOTAL_TELECOM, PROFILE_ID, BUSINESS_ID, KEYCODE, SIC, CVM_UNQ_ID) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
Nov 11, 2013 9:00:53 PM org.hibernate.engine.jdbc.spi.SqlExceptionHelper logExceptions
WARN: SQL Error: 926, SQLState: 42000
Nov 11, 2013 9:00:53 PM org.hibernate.engine.jdbc.spi.SqlExceptionHelper logExceptions
ERROR: ORA-00926: missing VALUES keyword
I’ve tried several different Oracle drivers thinking that could be the problem. I also read a post somewhere that one of the field names could be an Oracle keyword, but I removed all fields but the primary key to test and the error still occurs.
hibernate.cfg —
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<property name="show_sql">true</property>
<property name="hibernate.current_session_context_class">org.hibernate.context.internal.ThreadLocalSessionContext</property>
<property name="hibernate.connection.driver_class">oracle.jdbc.driver.OracleDriver</property>
<property name="hibernate.connection.password">oasisd_02</property>
<property name="hibernate.connection.url">jdbc:oracle:thin:@MyServer:1521/MyDB</property>
<property name="hibernate.connection.username">sa</property>
<property name="hibernate.default_catalog">MyDB</property>
<property name="hibernate.default_schema">dbo</property>
<property name="hibernate.dialect">org.hibernate.dialect.Oracle10gDialect</property>
<mapping class="myPrj.domain.Contact" resource="myPrj/domain/Contact.hbm.xml"/>
</session-factory>
</hibernate-configuration>
The mapping file is generated from JBOSS Tools in Eclipse.
Also, I’ve tried JDK 1.6 and 1.7
Updated — I should add that I am not using a custom HQL query.
Using a repository pattern —
public class ContactRepository implements IContactRepository {
public Contact find(String cvmUnqId) {
Session session = HibernateUtil.getSessionFactory().getCurrentSession();
session.beginTransaction();
Contact aContact = (Contact) session.load(Contact.class, cvmUnqId);
return aContact;
}
public Contact findByZipCode(String zipcode) {
// TODO Auto-generated method stub
return null;
}
public void store(Contact contact) {
Session session = HibernateUtil.getSessionFactory().getCurrentSession();
session.beginTransaction();
session.save(contact);
session.getTransaction().commit();
}
public void remove(Contact contact)
{
Session session = HibernateUtil.getSessionFactory().getCurrentSession();
session.beginTransaction();
session.delete(contact);
session.getTransaction().commit();
}
}
And the test case —
@Test
public void testContactList(){
ContactRepository contactRepo = new ContactRepository();
Object result = contactRepo.find("FakeID");
assertEquals(result, null);
}
@Test
public void addRemoveContactTest() {
ContactRepository contactRepo = new ContactRepository();
Contact contact = new Contact();
contact.setAddress("123 Anywhere");
contact.setArea('A');
contact.setAssignedRep('B');
contact.setBranchId('C');
contact.setBranchName('D');
contact.setBusinessId("Business ID");
contact.setBusinessName("Fake Business");
contact.setZip("11111");
contact.setCvmUnqId("FakeID");
contactRepo.store(contact);
Contact foundContact = contactRepo.find(contact.getCvmUnqId());
assertEquals("Contact was not found in repository", contact, foundContact);
contactRepo.remove(contact);
foundContact = contactRepo.find(contact.getCvmUnqId());
assertEquals("Contact was not removed from repository", null, foundContact);
}
And the factory utility in case thats relevant —
public class HibernateUtil {
private static SessionFactory sessionFactory = configureSessionFactory();
private static ServiceRegistry serviceRegistry;
private static SessionFactory configureSessionFactory() throws HibernateException {
Configuration configuration = new Configuration();
configuration.configure();
serviceRegistry = new ServiceRegistryBuilder().applySettings(configuration.getProperties()).buildServiceRegistry();
sessionFactory = configuration.buildSessionFactory(serviceRegistry);
return sessionFactory;
}
public static SessionFactory getSessionFactory() {
return sessionFactory;
}
}
Issue solved. The multi-part table identifier was incorrect. I removed the default catalog property from the hibernate configuration and it works fine now. I’m surprised it wasn’t a better error message from Oracle. Something like “table doesn’t exist”…
The easiest way to figure out which statement is causing the oracle errors is to connect a session to the database and turn on sql tracing or enable event 10046 trace.
to turn on tracing, use alter session set sql_trace=true
to turn on 10046 tracing one alter session set events ‘10046 trace name context forever, level 12’;
10046 can also be turned by the dba for other database sessions.
Then start the workload and analyze the corresponding trace file. The trace files are created in the directory specified by the init.ora parameter user_dump_dest.