Loading ...
Sorry, an error occurred while loading the content.

JPA, Hibernate and Firebird

Expand Messages
  • Laurent Duperval
    Hi, I am trying to create an implementation of our JPA application using Firebird 2, Hibernate and JPA. However, I am running into a few issues, and I wonder
    Message 1 of 4 , Dec 5, 2007
    • 0 Attachment
      Hi,

      I am trying to create an implementation of our JPA application using
      Firebird 2, Hibernate and JPA. However, I am running into a few issues,
      and I wonder if anyone can help.

      The goal is to have an identical implementation for all supported
      databases (so far only Postgres but I am trying to get a Firebird
      implementation).

      These are the main issues I have found so far:

      * When I try to create the database (using the JPA automation). I
      get this error, and I don't understand what it means:

      * 17:46:43,875 WARN [SettingsFactory] Could not obtain connection
      metadata
      org.firebirdsql.jdbc.FBSQLException: GDS Exception. 335544344. I/O
      error for file %.0s"CreateFile (open)"
      null
      Error while trying to open file
      null
      Reason: I/O error for file %.0s"CreateFile (open)"
      null
      Error while trying to open file
      null
      at
      org.firebirdsql.jdbc.FBDataSource.getConnection(FBDataSource.java:122)
      at org.firebirdsql.jdbc.FBDriver.connect(FBDriver.java:131)
      at
      java.sql.DriverManager.getConnection(DriverManager.java:525)
      at
      java.sql.DriverManager.getConnection(DriverManager.java:140)
      at
      org.hibernate.connection.DriverManagerConnectionProvider.getConnection(DriverManagerConnectionProvider.java:
      10)
      at
      org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:84)
      at
      org.hibernate.cfg.Configuration.buildSettings(Configuration.java:2009)
      at
      org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1292)
      at
      org.hibernate.cfg.AnnotationConfiguration.buildSessionFactory(AnnotationConfiguration.java:915)
      at
      org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:730)
      at
      org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePersistence.java:121)
      at
      javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:51)
      at
      javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:33)
      * I also get an error that says:
      javax.persistence.PersistenceException:
      org.hibernate.MappingException: Dialect does not support identity
      key generation. That, I understand. Is there a way to make this
      work without resorting to using a UUID (32 char) generator? Is
      there a generator that can be used/defined specifically for
      running under Firebird?

      For the creation error, I am aware that I could write the whole script
      by hand, but I don't really want that. I want to understand what the
      error is an how to work around it.

      Any help is greatly appreciated!

      Thanks,

      L


      [Non-text portions of this message have been removed]
    • Marcelo Siqueira
      ... Hi Laurent, I found myself with the same problem. So far I decided to use the TABLE identifier strategy and allow JPA to use a table to hold the primary
      Message 2 of 4 , Dec 5, 2007
      • 0 Attachment
        Laurent Duperval escreveu, em 5/12/2007 20:15:
        > * I also get an error that says:
        > javax.persistence.PersistenceException:
        > org.hibernate.MappingException: Dialect does not support identity
        > key generation. That, I understand. Is there a way to make this
        > work without resorting to using a UUID (32 char) generator? Is
        > there a generator that can be used/defined specifically for
        > running under Firebird?


        Hi Laurent,

        I found myself with the same problem. So far I decided to use the TABLE
        identifier strategy and allow JPA to use a table to hold the primary
        keys counters. I know this is not the optimal solution, but it will
        allow me to make the same code runs with Firebird and MySQL.

        Marcelo
      • Serge Bogatyrjov
        You don t need to use TABLE. This can help: @Id @GeneratedValue(strategy = GenerationType.AUTO) Integer id; Also you can use GenerationType.SEQUENCE, but it is
        Message 3 of 4 , Dec 5, 2007
        • 0 Attachment
          You don't need to use TABLE. This can help:

          @Id @GeneratedValue(strategy = GenerationType.AUTO)
          Integer id;

          Also you can use GenerationType.SEQUENCE, but it is dangerous. Then
          @SequenceGenerator can be used to set explisitly the used generator name.

          To get the answer on the first question you should provide database url (and
          check file permissions at first).


          2007/12/6, Marcelo Siqueira <mdm-listas@...>:
          >
          > Laurent Duperval escreveu, em 5/12/2007 20:15:
          > > * I also get an error that says:
          > > javax.persistence.PersistenceException:
          > > org.hibernate.MappingException: Dialect does not support identity
          > > key generation. That, I understand. Is there a way to make this
          > > work without resorting to using a UUID (32 char) generator? Is
          > > there a generator that can be used/defined specifically for
          > > running under Firebird?
          >
          > Hi Laurent,
          >
          > I found myself with the same problem. So far I decided to use the TABLE
          > identifier strategy and allow JPA to use a table to hold the primary
          > keys counters. I know this is not the optimal solution, but it will
          > allow me to make the same code runs with Firebird and MySQL.
          >
          > Marcelo
          >
          >
          >


          [Non-text portions of this message have been removed]
        • Marcelo Siqueira
          Hi Serge, ... I wish I could use that and let JPA automatically create the tables for me. But when JPA tries to create the sequence table, it issues the
          Message 4 of 4 , Dec 7, 2007
          • 0 Attachment
            Hi Serge,

            > You don't need to use TABLE. This can help:
            >
            > @Id @GeneratedValue(strategy = GenerationType.AUTO)
            > Integer id;


            I wish I could use that and let JPA automatically create the tables for
            me. But when JPA tries to create the sequence table, it issues the command:

            CREATE TABLE sequence (
            id_name VARCHAR(50) NOT NULL,
            id_seq NUMBER(19),
            PRIMARY KEY (id_name)
            )

            And an error happens because Firebird has no "NUMBER" type.

            Marcelo
          Your message has been successfully submitted and would be delivered to recipients shortly.