Hi everyone, I'm new with hibernate and I'm getting an error with SQLGrammarException:
Code:
Caused by: org.hibernate.exception.SQLGrammarException: could not load an entity: [br.com.datasul.hcm.eperformance.model.AcessoConteudoHistorico#1]
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:67)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
at org.hibernate.loader.Loader.loadEntity(Loader.java:1874)
at org.hibernate.loader.entity.AbstractEntityLoader.load(AbstractEntityLoader.java:48)
at org.hibernate.loader.entity.AbstractEntityLoader.load(AbstractEntityLoader.java:42)
at org.hibernate.persister.entity.AbstractEntityPersister.load(AbstractEntityPersister.java:3049)
at org.hibernate.event.def.DefaultLoadEventListener.loadFromDatasource(DefaultLoadEventListener.java:399)
at org.hibernate.event.def.DefaultLoadEventListener.doLoad(DefaultLoadEventListener.java:375)
at org.hibernate.event.def.DefaultLoadEventListener.load(DefaultLoadEventListener.java:139)
at org.hibernate.event.def.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:98)
at org.hibernate.impl.SessionImpl.fireLoad(SessionImpl.java:878)
at org.hibernate.impl.SessionImpl.immediateLoad(SessionImpl.java:836)
at org.hibernate.proxy.AbstractLazyInitializer.initialize(AbstractLazyInitializer.java:66)
at org.hibernate.proxy.AbstractLazyInitializer.getImplementation(AbstractLazyInitializer.java:111)
at org.hibernate.proxy.pojo.cglib.CGLIBLazyInitializer.invoke(CGLIBLazyInitializer.java:150)
at br.com.datasul.hcm.eperformance.model.AcessoConteudoHistorico$$EnhancerByCGLIB$$d3c550d7.getLiberaAcesso(<generated>)
at br.com.datasul.hcm.eperformance.presentation.ContaBean.getContaData(ContaBean.java:77)
at br.com.datasul.hcm.eperformance.presentation.ContaBean.salvar(ContaBean.java:189)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.el.parser.AstValue.invoke(AstValue.java:131)
at org.apache.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:276)
at com.sun.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:68)
at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:88)
... 75 more
Caused by: com.mysql.jdbc.exceptions.MySQLSyntaxErrorException: Unknown column 'acessocont0_.conta' in 'field list'
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:936)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:2985)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1631)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1723)
at com.mysql.jdbc.Connection.execSQL(Connection.java:3283)
at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:1332)
at com.mysql.jdbc.PreparedStatement.executeQuery(PreparedStatement.java:1467)
at org.jboss.resource.adapter.jdbc.WrappedPreparedStatement.executeQuery(WrappedPreparedStatement.java:342)
at org.hibernate.jdbc.AbstractBatcher.getResultSet(AbstractBatcher.java:186)
at org.hibernate.loader.Loader.getResultSet(Loader.java:1787)
at org.hibernate.loader.Loader.doQuery(Loader.java:674)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:236)
at org.hibernate.loader.Loader.loadEntity(Loader.java:1860)
... 98 more
I'm using this hbm.xml:
Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping package="br.com.datasul.hcm.eperformance.model">
<class name="AcessoConteudoHistorico" table="CONTAEXT">
<id name="codigo" type="java.lang.Long">
<column name="CONTAID" />
<generator class="foreign">
<param name="property">conta</param>
</generator>
</id>
<many-to-one name="conta" class="br.com.datasul.hcm.eperformance.model.Conta" not-found="ignore" not-null="false"></many-to-one>
<property name="liberaAcesso" type="java.lang.Integer" column="HAB_CONTEUDO" length="1" not-null="false"/>
</class>
</hibernate-mapping>
My mapped class is:
Code:
import java.io.Serializable;
import br.com.datasul.hcm.base.model.AbstractModel;
public class AcessoConteudoHistorico extends AbstractModel
{
private Long codigo;
private Integer liberaAcesso;
private Conta conta;
public Conta getConta() {
return conta;
}
public void setConta(Conta conta) {
this.conta = conta;
}
public Integer getLiberaAcesso() {
return liberaAcesso;
}
public void setLiberaAcesso(Integer liberaAcesso) {
this.liberaAcesso = liberaAcesso;
}
@Override
public Serializable getCodigo() {
return codigo;
}
@Override
public void setCodigo(Serializable arg0) {
this.codigo = (Long)codigo;
}
}
And in my database I have only two columns: CONTAEXT.CONTAID and CONTAEXT.HAB_CONTEUDO .
Could anyone help me ?
Thanks.