-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 7 posts ] 
Author Message
 Post subject: Firebird 2.5 Support?
PostPosted: Sun Dec 06, 2015 10:26 pm 
Newbie

Joined: Sun Nov 29, 2015 4:27 pm
Posts: 8
Hey,
I learn Hibernate and I wanted to build up their tables:
Code:
@Entity
@Table(name ="Language", schema="WebMuseum")
public class Test implements Serializable {

   @Id
   @Column(name="txn_details_id",nullable = false,columnDefinition = "varchar(50)")
   private String name;
   @Column
   private byte[] flag;
   
   public Test() {
      // TODO Auto-generated constructor stub
   }

   public Test(String name, byte[] flag) {
      super();
      this.name = name;
      this.flag = flag;
   }

   public String getName() {
      return name;
   }

   public void setName(String name) {
      this.name = name;
   }

   public byte[] getFlag() {
      return flag;
   }

   public void setFlag(byte[] flag) {
      this.flag = flag;
   }
   
   
}


Code:
INFO] Hibernate:
[INFO]     drop table Language
[ERROR] gru 07, 2015 3:12:45 AM org.hibernate.tool.hbm2ddl.SchemaExport perform
[ERROR] ERROR: HHH000389: Unsuccessful: drop table Language
[ERROR] gru 07, 2015 3:12:45 AM org.hibernate.tool.hbm2ddl.SchemaExport perform
[ERROR] ERROR: GDS Exception. 335544569. Dynamic SQL Error
[ERROR] SQL error code = -607
[ERROR] Invalid command
[ERROR] Table LANGUAGE does not exist
[INFO] Hibernate:
[INFO]     create table Language (
[INFO]         txn_details_id varchar(50) not null,
[INFO]         flag blob,
[INFO]         primary key (txn_details_id)
[INFO]     )
[ERROR] gru 07, 2015 3:12:45 AM org.hibernate.tool.hbm2ddl.SchemaExport perform
[ERROR] ERROR: HHH000389: Unsuccessful: create table Language (txn_details_id varchar(50) not null, flag blob, primary key (txn_details_id))
[ERROR] gru 07, 2015 3:12:45 AM org.hibernate.tool.hbm2ddl.SchemaExport perform
[ERROR] ERROR: GDS Exception. 335544351. unsuccessful metadata update
[ERROR] cannot create index RDB$PRIMARY19
[ERROR] gru 07, 2015 3:12:45 AM org.hibernate.tool.hbm2ddl.SchemaExport execute
[ERROR] INFO: HHH000230: Schema export complete


My version Hibernate is: 5.0.3.Final
My Firebird is: 2.5


Top
 Profile  
 
 Post subject: Re: Firebird 2.5 Support?
PostPosted: Mon Dec 07, 2015 5:05 am 
Hibernate Team
Hibernate Team

Joined: Thu Sep 11, 2014 2:50 am
Posts: 1628
Location: Romania
Can you post the Hibernate configuration properties?


Top
 Profile  
 
 Post subject: Re: Firebird 2.5 Support?
PostPosted: Mon Dec 07, 2015 6:24 am 
Newbie

Joined: Sun Nov 29, 2015 4:27 pm
Posts: 8
This my config:

Code:
<?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 name="">
  <property name="hibernate.connection.url">jdbc:firebirdsql://192.168.1.6:3050//baza/WebMuseum.fdb</property>
  <property name="hibernate.connection.username">xxx</property>
  <property name="hibernate.connection.password">xxx</property>
  <property name="format_sql">true</property>
  <property name="hibernate.show_sql">true</property>
  <property name="hibernate.use_sql_comments">true</property>
  <property name="hibernate.format_sql">true</property>
  <property name="hibernate.connection.driver_class">org.firebirdsql.jdbc.FBDriver</property>
  <property name="hibernate.dialect">org.hibernate.dialect.FirebirdDialect</property>
  <property name="hibernate.default_entity_mode">pojo</property>
  <property name="hibernate.hbm2ddl.auto">create</property>
</session-factory>
</hibernate-configuration>


Code:
public class HibernateUtils {

   private static final SessionFactory sessionFactory = buildSessionFactory();

   private static SessionFactory buildSessionFactory() {
      try {
         SessionFactory sessionFactory = new Configuration()
               .configure("/hibernate.cfg.xml")
               .addAnnotatedClass(Test.class)
               .buildSessionFactory();

         return sessionFactory;

      } catch (Throwable ex) {
         // log.error("Initial SessionFactory creation failed." + ex);
         throw new ExceptionInInitializerError(ex);
      }
   }

   public static SessionFactory getSessionFactory() {
      return sessionFactory;
   }

   public static void shutdown() {
      getSessionFactory().close();
   }
}



Top
 Profile  
 
 Post subject: Re: Firebird 2.5 Support?
PostPosted: Mon Dec 07, 2015 9:18 am 
Hibernate Team
Hibernate Team

Joined: Thu Sep 11, 2014 2:50 am
Posts: 1628
Location: Romania
Can you connect to the database and execute the create statement manually:

Code:
create table Language (
         txn_details_id varchar(50) not null,
        flag blob,
        primary key (txn_details_id)
)


If it doesn't work, then it's something with the database.


Top
 Profile  
 
 Post subject: Re: Firebird 2.5 Support?
PostPosted: Mon Dec 07, 2015 9:02 pm 
Newbie

Joined: Sun Nov 29, 2015 4:27 pm
Posts: 8
You're right. This previous DDL is wrong.

I thought it would be recognized at the "hibernate.dialect".

The correct DDL for my sample table looks like this:
Code:
CREATE TABLE LANGUAGE (
    TXN_DETAILS_ID VARCHAR(50) CHARACTER SET UTF8 NOT NULL COLLATE UTF8,
    FLAG BLOB);

ALTER TABLE LANGUAGE
ADD CONSTRAINT PK_LANGUAGE
PRIMARY KEY (TXN_DETAILS_ID);

Is it possible to obtain such DDL using POJO? If possible, ask for an example.

Does this mean that for each database (Firebird / MySQL) I have to prepare another POJO?

Regards


Top
 Profile  
 
 Post subject: Re: Firebird 2.5 Support?
PostPosted: Tue Dec 08, 2015 3:10 am 
Hibernate Team
Hibernate Team

Joined: Thu Sep 11, 2014 2:50 am
Posts: 1628
Location: Romania
You can open a Hibernate issue for this and switch to managing your schema manually. So you disable the hbmddl support and you can use FlywayDB to manage incremental schema upgrades.


Top
 Profile  
 
 Post subject: Re: Firebird 2.5 Support?
PostPosted: Sun Dec 13, 2015 1:29 pm 
Newbie

Joined: Sun Nov 29, 2015 4:27 pm
Posts: 8
mihalcea_vlad wrote:
You can open a Hibernate issue for this and switch to managing your schema manually. So you disable the hbmddl support and you can use FlywayDB to manage incremental schema upgrades.

So there is no 100% use Firebird? As a large percentage of the work is An advanced to make the full support?


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 7 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.