title: Error hibernate when i have two class. "org.hibernate.exception.SQLGrammarException: could not prepare statement
body: <p>Hello i´m newbie in Hibernate, JSF, Spring. I have  Empresa.java class with EmpresaBean, EmpresaDao, EmpresaService and i show a datatable with primefaces. It works perfect. Now I have only a new  Ldiario class. Empresa.java and Ldiario.java are OneToOne in Hibernate but when i compile i have this error. Sorry  my english. I´m learning it.</p>
  
  <p><strong>Error</strong></p>
  
  <pre><code>Hibernate: select empresa0_.CLAVE as CLAVE1_1_, empresa0_.ACT_CONTRASE as ACT2_1_, empresa0_.ADMON as ADMON3_1_, empresa0_.BALANCE as BALANCE4_1_, empresa0_.BALANCE_UE as BALANCE5_1_, empresa0_.COBROS as COBROS6_1_, empresa0_.CODPAIS as CODPAIS7_1_, empresa0_.CODPOSTAL as CODPOSTA8_1_, empresa0_.CONTACTO as CONTACTO9_1_, empresa0_.CONTRASE as CONTRAS10_1_, empresa0_.COOPERA as COOPERA11_1_, empresa0_.CORREO as CORREO12_1_, empresa0_.CRITERIOCAJA as CRITERI13_1_, empresa0_.DNICIF as DNICIF14_1_, empresa0_.DOC3W_AUTOGESTION as DOC15_1_, empresa0_.DOC3W_REFURL as DOC16_1_, empresa0_.EJERCICIO as EJERCIC17_1_, empresa0_.E_RETEN as E18_1_, empresa0_.FAX as FAX19_1_, empresa0_.FECHAFIN as FECHAFI20_1_, empresa0_.FECHAINI as FECHAIN21_1_, empresa0_.FECHA_BAJA as FECHA22_1_, empresa0_.FOLIO_R as FOLIO23_1_, empresa0_.GES_DOCU as GES24_1_, empresa0_.GES_PROYECTOS as GES25_1_, empresa0_.HOJA_R as HOJA26_1_, empresa0_.IGIC_IVA as IGIC27_1_, empresa0_.ILOGO as ILOGO28_1_, empresa0_.INUMERO as INUMERO29_1_, empresa0_.LIBRO_R as LIBRO30_1_, empresa0_.LOGO as LOGO31_1_, empresa0_.MOVILCONTACTO as MOVILCO32_1_, empresa0_.MUNICIPIO as MUNICIP33_1_, empresa0_.NIVEL as NIVEL34_1_, empresa0_.NOMBRE as NOMBRE35_1_, empresa0_.NUMERO as NUMERO36_1_, empresa0_.OBSERVACIONES as OBSERVA37_1_, empresa0_.OCUPADO as OCUPADO38_1_, empresa0_.OTROS_R as OTROS39_1_, empresa0_.PAG_ASIEN as PAG40_1_, empresa0_.PISO as PISO41_1_, empresa0_.PROVINCIA as PROVINC42_1_, empresa0_.PUERTA as PUERTA43_1_, empresa0_.REGCOMPRAS as REGCOMP44_1_, empresa0_.REGMER as REGMER45_1_, empresa0_.REGVENTAS as REGVENT46_1_, empresa0_.SECCION_R as SECCION47_1_, empresa0_.SIGLA as SIGLA48_1_, empresa0_.SUBC_DESP1 as SUBC49_1_, empresa0_.SUBC_DESP2 as SUBC50_1_, empresa0_.SUBC_DESP3 as SUBC51_1_, empresa0_.SUBC_DESP4 as SUBC52_1_, empresa0_.SUBC_DESP7 as SUBC53_1_, empresa0_.SUBC_DESPC1 as SUBC54_1_, empresa0_.SUBC_DESPI1 as SUBC55_1_, empresa0_.SUBC_DESPI2 as SUBC56_1_, empresa0_.SUBC_DESPI3 as SUBC57_1_, empresa0_.SUBC_DESPI4 as SUBC58_1_, empresa0_.SUBC_DESPI5 as SUBC59_1_, empresa0_.SUBC_DESPI6 as SUBC60_1_, empresa0_.TELEFONO as TELEFON61_1_, empresa0_.TELEFONO_CONT as TELEFON62_1_, empresa0_.TIPO_EMP as TIPO63_1_, empresa0_.TIPO_R as TIPO64_1_, empresa0_.TOMO_R as TOMO65_1_, empresa0_.VIAPUBLICA as VIAPUBL66_1_, empresa0_.WEB as WEB67_1_, empresa0_.WEBCONTACTO as WEBCONT68_1_ from empresas empresa0_
  Hibernate: select ldiario0_.CLAVE as CLAVE1_0_1_, ldiario0_.ASIENTO as ASIENTO2_0_1_, ldiario0_.ASIENTOREOR as ASIENTOR3_0_1_, ldiario0_.BASE_EXEN as BASE4_0_1_, ldiario0_.BASE_RET_D as BASE5_0_1_, ldiario0_.BASE_RET_E as BASE6_0_1_, ldiario0_.CONCEPTO as CONCEPTO7_0_1_, ldiario0_.CUO_EXEN as CUO8_0_1_, ldiario0_.CUO_RET_D as CUO9_0_1_, ldiario0_.CUO_RET_E as CUO10_0_1_, ldiario0_.DEBE as DEBE11_0_1_, ldiario0_.DEBE_E as DEBE12_0_1_, ldiario0_.DIVISA as DIVISA13_0_1_, ldiario0_.DOCUMENTO as DOCUMEN14_0_1_, ldiario0_.FACTURA as FACTURA15_0_1_, ldiario0_.FECHA as FECHA16_0_1_, ldiario0_.HABER as HABER17_0_1_, ldiario0_.HABER_E as HABER18_0_1_, ldiario0_.LOCALIZADOR as LOCALIZ19_0_1_, ldiario0_.NDOCU as NDOCU20_0_1_, ldiario0_.ORDEN as ORDEN21_0_1_, ldiario0_.ORDENREOR as ORDENRE22_0_1_, ldiario0_.PORC_EXEN as PORC23_0_1_, ldiario0_.PORC_RET_D as PORC24_0_1_, ldiario0_.PORC_RET_E as PORC25_0_1_, ldiario0_.PROYECTO as PROYECT26_0_1_, ldiario0_.PUNTEADO as PUNTEAD27_0_1_, ldiario0_.SALDO as SALDO28_0_1_, ldiario0_.SUBCUENTA as SUBCUEN29_0_1_, ldiario0_.SUBNOMBRE as SUBNOMB30_0_1_, ldiario0_.TEXTO as TEXTO31_0_1_, ldiario0_.TIPO as TIPO32_0_1_, empresa1_.CLAVE as CLAVE1_1_0_, empresa1_.ACT_CONTRASE as ACT2_1_0_, empresa1_.ADMON as ADMON3_1_0_, empresa1_.BALANCE as BALANCE4_1_0_, empresa1_.BALANCE_UE as BALANCE5_1_0_, empresa1_.COBROS as COBROS6_1_0_, empresa1_.CODPAIS as CODPAIS7_1_0_, empresa1_.CODPOSTAL as CODPOSTA8_1_0_, empresa1_.CONTACTO as CONTACTO9_1_0_, empresa1_.CONTRASE as CONTRAS10_1_0_, empresa1_.COOPERA as COOPERA11_1_0_, empresa1_.CORREO as CORREO12_1_0_, empresa1_.CRITERIOCAJA as CRITERI13_1_0_, empresa1_.DNICIF as DNICIF14_1_0_, empresa1_.DOC3W_AUTOGESTION as DOC15_1_0_, empresa1_.DOC3W_REFURL as DOC16_1_0_, empresa1_.EJERCICIO as EJERCIC17_1_0_, empresa1_.E_RETEN as E18_1_0_, empresa1_.FAX as FAX19_1_0_, empresa1_.FECHAFIN as FECHAFI20_1_0_, empresa1_.FECHAINI as FECHAIN21_1_0_, empresa1_.FECHA_BAJA as FECHA22_1_0_, empresa1_.FOLIO_R as FOLIO23_1_0_, empresa1_.GES_DOCU as GES24_1_0_, empresa1_.GES_PROYECTOS as GES25_1_0_, empresa1_.HOJA_R as HOJA26_1_0_, empresa1_.IGIC_IVA as IGIC27_1_0_, empresa1_.ILOGO as ILOGO28_1_0_, empresa1_.INUMERO as INUMERO29_1_0_, empresa1_.LIBRO_R as LIBRO30_1_0_, empresa1_.LOGO as LOGO31_1_0_, empresa1_.MOVILCONTACTO as MOVILCO32_1_0_, empresa1_.MUNICIPIO as MUNICIP33_1_0_, empresa1_.NIVEL as NIVEL34_1_0_, empresa1_.NOMBRE as NOMBRE35_1_0_, empresa1_.NUMERO as NUMERO36_1_0_, empresa1_.OBSERVACIONES as OBSERVA37_1_0_, empresa1_.OCUPADO as OCUPADO38_1_0_, empresa1_.OTROS_R as OTROS39_1_0_, empresa1_.PAG_ASIEN as PAG40_1_0_, empresa1_.PISO as PISO41_1_0_, empresa1_.PROVINCIA as PROVINC42_1_0_, empresa1_.PUERTA as PUERTA43_1_0_, empresa1_.REGCOMPRAS as REGCOMP44_1_0_, empresa1_.REGMER as REGMER45_1_0_, empresa1_.REGVENTAS as REGVENT46_1_0_, empresa1_.SECCION_R as SECCION47_1_0_, empresa1_.SIGLA as SIGLA48_1_0_, empresa1_.SUBC_DESP1 as SUBC49_1_0_, empresa1_.SUBC_DESP2 as SUBC50_1_0_, empresa1_.SUBC_DESP3 as SUBC51_1_0_, empresa1_.SUBC_DESP4 as SUBC52_1_0_, empresa1_.SUBC_DESP7 as SUBC53_1_0_, empresa1_.SUBC_DESPC1 as SUBC54_1_0_, empresa1_.SUBC_DESPI1 as SUBC55_1_0_, empresa1_.SUBC_DESPI2 as SUBC56_1_0_, empresa1_.SUBC_DESPI3 as SUBC57_1_0_, empresa1_.SUBC_DESPI4 as SUBC58_1_0_, empresa1_.SUBC_DESPI5 as SUBC59_1_0_, empresa1_.SUBC_DESPI6 as SUBC60_1_0_, empresa1_.TELEFONO as TELEFON61_1_0_, empresa1_.TELEFONO_CONT as TELEFON62_1_0_, empresa1_.TIPO_EMP as TIPO63_1_0_, empresa1_.TIPO_R as TIPO64_1_0_, empresa1_.TOMO_R as TOMO65_1_0_, empresa1_.VIAPUBLICA as VIAPUBL66_1_0_, empresa1_.WEB as WEB67_1_0_, empresa1_.WEBCONTACTO as WEBCONT68_1_0_ from LDIARIO1014 ldiario0_ left outer join empresas empresa1_ on ldiario0_.CLAVE=empresa1_.CLAVE where ldiario0_.CLAVE=?
  dic 11, 2014 4:43:36 PM org.hibernate.engine.jdbc.spi.SqlExceptionHelper logExceptions
  WARN: SQL Error: 335544569, SQLState: 42000
  dic 11, 2014 4:43:36 PM org.hibernate.engine.jdbc.spi.SqlExceptionHelper logExceptions
  ERROR: GDS Exception. 335544569. Dynamic SQL Error
  SQL error code = -204
  Table unknown
  LDIARIO1014
  At line 1, column 3648
  dic 11, 2014 4:43:36 PM org.hibernate.event.internal.DefaultLoadEventListener onLoad
  INFO: HHH000327: Error performing load command : org.hibernate.exception.SQLGrammarException: could not prepare statement
  dic 11, 2014 4:43:36 PM com.sun.faces.application.view.FaceletViewHandlingStrategy handleRenderException
  Grave: Error Rendering View[//pages/index.xhtml]
  javax.el.ELException: /pages/index.xhtml @15,73 value="#{empresaBean.getEmpresaList()}": org.hibernate.exception.SQLGrammarException: could not prepare statement
      at com.sun.faces.facelets.el.TagValueExpression.getValue(TagValueExpression.java:114)
      at javax.faces.component.ComponentStateHelper.eval(ComponentStateHelper.java:194)
      at javax.faces.component.ComponentStateHelper.eval(ComponentStateHelper.java:182)
      at javax.faces.component.UIData.getValue(UIData.java:731)
  </code></pre>
  
  <p><strong>Empresa.java</strong></p>
  
  <pre><code>@Entity
  @Table(name = "empresas")
  public class Empresa implements Serializable{
  
  @Id 
  @Column(name = "CLAVE")
  @GeneratedValue private int CLAVE;
  
  
  @OneToOne(mappedBy = "empresa", cascade = CascadeType.ALL)  
  private Ldiario ldiario;  
  
  @Column(name = "NOMBRE")
  private String NOMBRE;
  </code></pre>
  
  <p><strong>EmpresaDaoImpl.java</strong></p>
  
  <pre><code>@Override
  public List&lt;Empresa&gt; findAll() {
      return sessionFactory.getCurrentSession().createQuery("from Empresa").list();
  }
  </code></pre>
  
  <p><strong>jdbc.properties</strong></p>
  
  <pre><code>jdbc.driverClassName= org.firebirdsql.jdbc.FBDriver
  jdbc.dialect=org.hibernate.dialect.FirebirdDialect
  jdbc.databaseurl=jdbc:firebirdsql:PROSYTH-PC/3050:C:/aplifisa/contcs/CONTBD
  jdbc.username=SYSDBA
  jdbc.password=masterkey
  jdbc.validationQuery=Select 1 from rdb$database
  </code></pre>
  
  <p><strong>Ldiario.java</strong></p>
  
  <pre><code>@Entity
  @Table(name = "LDIARIO1014")
  public class Ldiario implements Serializable{
  
  
  @Id 
  @Column(name = "CLAVE")
  @GeneratedValue private int CLAVE;  
  
  @OneToOne  
  @PrimaryKeyJoinColumn  
  private Empresa empresa;
  
  @Column(name = "ASIENTO")
  private int ASIENTO;
  </code></pre>
  
  <p>Do I have to create LdiarioDao . LdiarioService ... etc etc or not needed ? Thank you.</p>