-->
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.  [ 14 posts ] 
Author Message
 Post subject: Diffrent deployment on MySQL using Windows or Linux.
PostPosted: Thu Mar 29, 2007 9:57 am 
Newbie

Joined: Thu Mar 29, 2007 9:07 am
Posts: 7
Hello,

When I run the following Program i get different results when the database runs on Windows and on Linux. The program is very simple. It creates users and lists them. The outcome of the programs are exactly the same. though the generated databases are difrent. (note the cases on table names and eventually on column names) The program also throws unhandled exceptions when the database is running on a linux machine.

Why does the database on linux generate this error?

Is the hibernate implementation using diffrent versions for mysql on linux and on windows?

Is it some sort of setting in mysql or hibernate?

any help is much appriciated...

thanx in advance

- Xander


----------- General info ---------------
Hibernate version: 3.1.3

Name and version of the database you are using:
Linux: MySQL 5.0.34
Windows MySQL 5.0.37


------ Windows ------------
Code:
mysql> use nieuwetest
Database changed
mysql> describe user;
+------------+--------------+------+-----+---------+----------------+
| Field      | Type         | Null | Key | Default | Extra          |
+------------+--------------+------+-----+---------+----------------+
| ID         | bigint(20)   | NO   | PRI | NULL    | auto_increment |
| ENABLED    | tinyint(4)   | NO   |     |         |                |
| USERNAME   | varchar(255) | NO   | UNI |         |                |
| EMAIL      | varchar(255) | NO   |     |         |                |
| FIRST_NAME | varchar(255) | NO   |     |         |                |
| LAST_NAME  | varchar(255) | NO   |     |         |                |
+------------+--------------+------+-----+---------+----------------+
6 rows in set (0.04 sec)

mysql> show tables;
+----------------------+
| Tables_in_nieuwetest |
+----------------------+
| user                 |
+----------------------+
1 row in set (0.00 sec)


----------- Linux ---------------
Code:
mysql> use nieuwetest;
Database changed
mysql> describe user;
ERROR 1146 (42S02): Table 'nieuwetest.user' doesn't exist
mysql> describe USER;
+------------+--------------+------+-----+---------+----------------+
| Field      | Type         | Null | Key | Default | Extra          |
+------------+--------------+------+-----+---------+----------------+
| ID         | bigint(20)   | NO   | PRI | NULL    | auto_increment |
| ENABLED    | tinyint(4)   | NO   |     |         |                |
| USERNAME   | varchar(255) | NO   | UNI |         |                |
| EMAIL      | varchar(255) | NO   |     |         |                |
| FIRST_NAME | varchar(255) | NO   |     |         |                |
| LAST_NAME  | varchar(255) | NO   |     |         |                |
+------------+--------------+------+-----+---------+----------------+
6 rows in set (0.01 sec)

mysql> show tables;
+----------------------+
| Tables_in_nieuwetest |
+----------------------+
| USER                 |
+----------------------+
1 row in set (0.00 sec)




----------- Stack trace when running on linux 2nd time ---------------
Code:
15:49:05,747 ERROR JDBCExceptionReporter:72 - Unknown database 'NIEUWETEST'
15:49:05,749 ERROR SchemaUpdate:165 - could not complete schema update
org.hibernate.exception.SQLGrammarException: could not get table metadata: USER
   at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:67)
   at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
   at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:29)
   at org.hibernate.tool.hbm2ddl.DatabaseMetadata.getTableMetadata(DatabaseMetadata.java:100)
   at org.hibernate.cfg.Configuration.generateSchemaUpdateScript(Configuration.java:838)
   at org.hibernate.tool.hbm2ddl.SchemaUpdate.execute(SchemaUpdate.java:140)
   at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:296)
   at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1176)
   at nl.ap400.test.hibernate.InitSessionFactory.initSessionFactory(InitSessionFactory.java:45)
   at nl.ap400.test.hibernate.InitSessionFactory.getInstance(InitSessionFactory.java:20)
   at nl.ap400.test.hibernate.MainApp.createUser(MainApp.java:53)
   at nl.ap400.test.hibernate.MainApp.main(MainApp.java:25)
Caused by: java.sql.SQLException: Unknown database 'NIEUWETEST'
   at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:2926)
   at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1571)
   at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1666)
   at com.mysql.jdbc.Connection.execSQL(Connection.java:2972)
   at com.mysql.jdbc.Connection.execSQL(Connection.java:2902)
   at com.mysql.jdbc.Statement.executeQuery(Statement.java:822)
   at com.mysql.jdbc.DatabaseMetaData$9.forEach(DatabaseMetaData.java:4453)
   at com.mysql.jdbc.DatabaseMetaData$IterateBlock.doForAll(DatabaseMetaData.java:79)
   at com.mysql.jdbc.DatabaseMetaData.getTables(DatabaseMetaData.java:4440)
   at com.mysql.jdbc.DatabaseMetaData$2.forEach(DatabaseMetaData.java:1928)
   at com.mysql.jdbc.DatabaseMetaData$IterateBlock.doForAll(DatabaseMetaData.java:79)
   at com.mysql.jdbc.DatabaseMetaData.getColumns(DatabaseMetaData.java:1894)
   at org.hibernate.tool.hbm2ddl.TableMetadata.initColumns(TableMetadata.java:177)
   at org.hibernate.tool.hbm2ddl.TableMetadata.<init>(TableMetadata.java:33)
   at org.hibernate.tool.hbm2ddl.DatabaseMetadata.getTableMetadata(DatabaseMetadata.java:85)
   ... 8 more




CODE & CONFIG

----------- Hibernate 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">

<!-- Generated by MyEclipse Hibernate Tools.                   -->
<hibernate-configuration>

<session-factory>
   <property name="connection.url">
      jdbc:mysql://localhost:3306/nieuwetest
   </property>

   <property name="connection.username">root</property>
   <property name="connection.password"></property>
   <property name="connection.driver_class">
      com.mysql.jdbc.Driver
   </property>
   <property name="dialect">
      org.hibernate.dialect.MySQLInnoDBDialect
   </property>
   <property name="show_sql">true</property>
   <property name="transaction.factory_class">org.hibernate.transaction.JDBCTransactionFactory</property>
   <property name="current_session_context_class">thread</property>
   <property name="hbm2ddl.auto">update</property>
   <mapping resource="nl/ap400/test/hibernate/User.hbm.xml" />

</session-factory>

</hibernate-configuration>


---------- User.hbm.xml -----------
Code:
<?xml version="1.0" encoding="UTF-8"?>
<!--
     Attention: Generated code! Do not modify by hand!
     Generated by: hibernate.hbm.xml.vsl in andromda-hibernate-cartridge.
  -->
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
          "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">

<hibernate-mapping default-cascade="none">
    <class name="nl.ap400.test.hibernate.User" table="USER" dynamic-insert="false" dynamic-update="false">
        <id name="id" type="java.lang.Long" unsaved-value="null">
            <column name="ID" sql-type="BIGINT"/>
            <generator class="native">
            </generator>
        </id>

        <property name="enabled" type="boolean">
            <column name="ENABLED" not-null="true" unique="false" sql-type="TINYINT"/>
        </property>
        <property name="username" type="java.lang.String">
            <column name="USERNAME" not-null="true" unique="false" unique-key="usernameUnique" sql-type="VARCHAR(255) BINARY"/>
        </property>
        <property name="email" type="java.lang.String">
            <column name="EMAIL" not-null="true" unique="false" sql-type="VARCHAR(255) BINARY"/>
        </property>
        <property name="firstName" type="java.lang.String">
            <column name="FIRST_NAME" not-null="true" unique="false" sql-type="VARCHAR(255) BINARY"/>
        </property>
        <property name="lastName" type="java.lang.String">
            <column name="LAST_NAME" not-null="true" unique="false" sql-type="VARCHAR(255) BINARY"/>
        </property>

    </class>
</hibernate-mapping>


---------- User.java ----------
Code:
package nl.ap400.test.hibernate;

import java.io.Serializable;

public class User implements Serializable {
    private static final long serialVersionUID = -5356167726657927602L;

    private java.lang.Long id;

    private java.lang.String username;
   
    private java.lang.String password;
   
    private java.lang.String firstName;

    private java.lang.String lastName;

    private java.lang.String email;

    private boolean enabled;
   
    public boolean equals(Object object)  {
        if (this == object)
        {
            return true;
        }
        if (!(object instanceof User))
        {
            return false;
        }
        final User that = (User)object;
        if (this.id == null || that.getId() == null || !this.id.equals(that.getId()))
        {
            return false;
        }
        return true;
    }

    public String toString() {
       return "@" + id + " " + firstName + " " + lastName;
    }

   public java.lang.String getEmail() {
      return email;
   }

   public boolean isEnabled() {
      return enabled;
   }

   public java.lang.String getFirstName() {
      return firstName;
   }

   public java.lang.Long getId() {
      return id;
   }

   public java.lang.String getLastName() {
      return lastName;
   }

   public java.lang.String getPassword() {
      return password;
   }

   public java.lang.String getUsername() {
      return username;
   }

   public void setEmail(java.lang.String email) {
      this.email = email;
   }

   public void setEnabled(boolean enabled) {
      this.enabled = enabled;
   }

   public void setFirstName(java.lang.String firstName) {
      this.firstName = firstName;
   }

   public void setId(java.lang.Long id) {
      this.id = id;
   }

   public void setLastName(java.lang.String lastName) {
      this.lastName = lastName;
   }

   public void setPassword(java.lang.String password) {
      this.password = password;
   }

   public void setUsername(java.lang.String username) {
      this.username = username;
   }
}


--------------- MainApp.java -----------------
Code:
package nl.ap400.test.hibernate;

import java.util.Iterator;
import java.util.List;

import org.apache.log4j.Logger;
import org.hibernate.HibernateException;
import org.hibernate.Transaction;
import org.hibernate.classic.Session;

public class MainApp {
   private static Logger log = Logger.getLogger(MainApp.class);

   public static void main(String[] args) {
      
      for (int i = 0; i < 10; i++) {
         User user = new User();
         user.setEmail("my@email.com");
         user.setFirstName("xander");
         user.setLastName("wiseGuy");
         user.setEnabled(true);
         user.setPassword("secret");
         user.setUsername("xander_"+i);
      
         createUser(user);
      }
            
      listUser();

   }

   private static void listUser() {
      Transaction tx = null;
      Session session = InitSessionFactory.getInstance().getCurrentSession();
      try {
         tx = session.beginTransaction();
         List Users = session.createQuery("select u from User as u").list();
         for (Iterator iter = Users.iterator(); iter.hasNext();) {
            User element = (User) iter.next();
            log.info(element);
         }
         tx.commit();
      } catch (HibernateException e) {
         e.printStackTrace();
         if (tx != null && tx.isActive())
            tx.rollback();

      }
   }

   private static void createUser(User User) {
      Transaction tx = null;
      Session session = InitSessionFactory.getInstance().getCurrentSession();
      try {
         tx = session.beginTransaction();
         session.save(User);
         tx.commit();
      } catch (HibernateException e) {
         e.printStackTrace();
         if (tx != null && tx.isActive())
            tx.rollback();
      }
   }
}


-------------------- InitSessionFactory.java ---------------------
Code:
package nl.ap400.test.hibernate;

import javax.naming.InitialContext;

import org.hibernate.HibernateException;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;
import org.hibernate.cfg.Environment;

public class InitSessionFactory {

   private static final Configuration cfg = new Configuration();
   private static org.hibernate.SessionFactory sessionFactory;

   private static String CONFIG_FILE_LOCATION = "/hibernate.cfg.xml";


   public static SessionFactory getInstance() {
      if (sessionFactory == null) initSessionFactory();
      return sessionFactory;
   }

   public Session getCurrentSession() {
      return sessionFactory.getCurrentSession();
   }

   public static void close(){
      if (sessionFactory != null) sessionFactory.close();
      sessionFactory = null;
   }

   private static synchronized void initSessionFactory() {
      if (sessionFactory == null) {
         
         try {
            cfg.configure(CONFIG_FILE_LOCATION);
            String sessionFactoryJndiName = cfg.getProperty(Environment.SESSION_FACTORY_NAME);
            
            if (sessionFactoryJndiName != null) {
               cfg.buildSessionFactory();
               sessionFactory = (SessionFactory) (new InitialContext())
                     .lookup(sessionFactoryJndiName);
            } else{
               sessionFactory = cfg.buildSessionFactory();
            }

         } catch (Exception ex) {
            throw new HibernateException("Could not initialize the Hibernate configuration", ex);
         }
         
      }
   }
}


----------------- log4j.properties ------------------------
Code:
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.Target=System.out
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}:%L - %m%n
log4j.logger.org.hibernate=info
log4j.logger.org.hibernate.SQL=debug
log4j.logger.org.hibernate.type=info
log4j.logger.org.hibernate.tool.hbm2ddl=info
log4j.logger.org.hibernate.cache=info


Last edited by Xandy on Thu Mar 29, 2007 3:11 pm, edited 1 time in total.

Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 29, 2007 12:09 pm 
Regular
Regular

Joined: Thu Dec 22, 2005 7:47 am
Posts: 62
Location: Czech Republic
on linux, the default MySQL db engine is MyISAM -- the database is stored on a filesystem on plain files. In case you use that (its the default for Linux -- windows use innodb engine) Linux filesystem is case sensitive, pls check that you refer with correct case to your tables and database.

if you database is "small_case" you should bnot connect to it as "SMALL_CASE", the same for tables.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 29, 2007 3:10 pm 
Newbie

Joined: Thu Mar 29, 2007 9:07 am
Posts: 7
mar wrote:
on linux, the default MySQL db engine is MyISAM -- the database is stored on a filesystem on plain files. In case you use that (its the default for Linux -- windows use innodb engine) Linux filesystem is case sensitive, pls check that you refer with correct case to your tables and database.


is that even though i set my dialect to:

Code:
<property name="dialect">
      org.hibernate.dialect.MySQLInnoDBDialect
</property>



Should i change my mysql settings or can i change de hibernate properties in such way that the Database is working as intended?

Quote:
if you database is "small_case" you should bnot connect to it as "SMALL_CASE", the same for tables.


i understand that... but this is done by hibernate... i just dont understand why hibernate does that..


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 30, 2007 8:06 am 
Regular
Regular

Joined: Thu Dec 22, 2005 7:47 am
Posts: 62
Location: Czech Republic
hibernate just exports the schema, the database creation (and so the choose of mysql db engine) is completely in your hands as far as i know.

you also provide the connection properties, but they have to be real -- so choose the innodb dialect only if the database you have created is using the innodb engine. see mysql manual how to create the innodb database on linux (if you ever need it).

i have mysql windows and linux installation which work just fine -- and i use org.hibernate.dialect.MySQLDialect with innodb (windows, linux) and myisam (linux) -- on both systems/db engines i use the same setting.

i use those commands to create the database on linux/windows

Code:
- - - - MySQL commands - - - -

mysql -h localhost -u root -pXXX mysql
CREATE DATABASE test CHARACTER SET utf8;
GRANT ALL PRIVILEGES ON test.* TO 'test'@'localhost' IDENTIFIED BY 'test';


Code:
# MySQL
db.dialect = org.hibernate.dialect.MySQLDialect
db.driver  = com.mysql.jdbc.Driver
db.uri     = jdbc:mysql://localhost/test
db.user    = test
db.pass    = test
# options: useUnicode=true, characterEncoding=UTF-8


Top
 Profile  
 
 Post subject:
PostPosted: Wed Apr 04, 2007 7:33 am 
Newbie

Joined: Thu Mar 29, 2007 9:07 am
Posts: 7
mar wrote:
hibernate just exports the schema, the database creation (and so the choose of mysql db engine) is completely in your hands as far as i know.

you also provide the connection properties, but they have to be real -- so choose the innodb dialect only if the database you have created is using the innodb engine. see mysql manual how to create the innodb database on linux (if you ever need it).


Sorry for my late reply, my job demanded different attention. I restarted my MySQL server (on Linux) using innodb as default engine and as default table type. When i run the program it creates the table of type InnoDB. But it still gives me the SQLException about not finding the database with capital characters. And also the tablename written with capital characters. See here the mysql dump information (of my Linux Box):

Code:
CREATE TABLE `USER` (
  `ID` bigint(20) NOT NULL auto_increment,
  `ENABLED` tinyint(4) NOT NULL,
  `USERNAME` varchar(255) character set utf8 collate utf8_bin NOT NULL,
  `EMAIL` varchar(255) character set utf8 collate utf8_bin NOT NULL,
  `FIRST_NAME` varchar(255) character set utf8 collate utf8_bin NOT NULL,
  `LAST_NAME` varchar(255) character set utf8 collate utf8_bin NOT NULL,
  PRIMARY KEY  (`ID`),
  UNIQUE KEY `USERNAME` (`USERNAME`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;


Thanx for already helping me out.

gr. Xander


Top
 Profile  
 
 Post subject:
PostPosted: Fri Apr 13, 2007 3:16 am 
Regular
Regular

Joined: Thu Dec 22, 2005 7:47 am
Posts: 62
Location: Czech Republic
ok, i see the engine used is innodb in table creation. what about the database?

two more questions:

1. Can you connect to your database using soem JDBC client program (SQuirreL)? If so, you should be able to connect with hibernate (I never experienced a problem that I prevent me from connecting while i was able to use plain JDBC).

2. How do you set up the Linux machine. Setting the innodb on linux is not so straight forward process -- you need to create a innodb database file. Have you done that?


Top
 Profile  
 
 Post subject:
PostPosted: Fri Apr 13, 2007 4:32 am 
Newbie

Joined: Thu Mar 29, 2007 9:07 am
Posts: 7
mar wrote:
ok, i see the engine used is innodb in table creation. what about the database?

see your second question. i take it that it creates innodb as default. Do you know how to check it?

mar wrote:
1. Can you connect to your database using soem JDBC client program (SQuirreL)? If so, you should be able to connect with hibernate (I never experienced a problem that I prevent me from connecting while i was able to use plain JDBC).

I can connect to the database using JDBC. But the problem is not the connection but why hibernate chooses to use diffrent cases on diffrent os's which brings it in troubles when trying to connect to it the second time.

mar wrote:
2. How do you set up the Linux machine. Setting the innodb on linux is not so straight forward process -- you need to create a innodb database file. Have you done that?


I reconfigured the following two options in my /etc/mysql/my.cnf :
Code:
default-storage-engine = InnoDB
default-table-type = InnoDB


The result is the following:
Code:
mysql> show engines;
+------------+---------+----------------------------------------------------------------+
| Engine     | Support | Comment                                                        |
+------------+---------+----------------------------------------------------------------+
| MyISAM     | YES     | Default engine as of MySQL 3.23 with great performance         |
| MEMORY     | YES     | Hash based, stored in memory, useful for temporary tables      |
| InnoDB     | DEFAULT | Supports transactions, row-level locking, and foreign keys     |
| BerkeleyDB | YES     | Supports transactions and page-level locking                   |
| BLACKHOLE  | NO      | /dev/null storage engine (anything you write to it disappears) |
| EXAMPLE    | NO      | Example storage engine                                         |
| ARCHIVE    | NO      | Archive storage engine                                         |
| CSV        | NO      | CSV storage engine                                             |
| ndbcluster | NO      | Clustered, fault-tolerant, memory-based tables                 |
| FEDERATED  | NO      | Federated MySQL storage engine                                 |
| MRG_MYISAM | YES     | Collection of identical MyISAM tables                          |
| ISAM       | NO      | Obsolete storage engine                                        |
+------------+---------+----------------------------------------------------------------+
12 rows in set (0.00 sec)

mysql> show table types;
+------------+---------+----------------------------------------------------------------+
| Engine     | Support | Comment                                                        |
+------------+---------+----------------------------------------------------------------+
| MyISAM     | YES     | Default engine as of MySQL 3.23 with great performance         |
| MEMORY     | YES     | Hash based, stored in memory, useful for temporary tables      |
| InnoDB     | DEFAULT | Supports transactions, row-level locking, and foreign keys     |
| BerkeleyDB | YES     | Supports transactions and page-level locking                   |
| BLACKHOLE  | NO      | /dev/null storage engine (anything you write to it disappears) |
| EXAMPLE    | NO      | Example storage engine                                         |
| ARCHIVE    | NO      | Archive storage engine                                         |
| CSV        | NO      | CSV storage engine                                             |
| ndbcluster | NO      | Clustered, fault-tolerant, memory-based tables                 |
| FEDERATED  | NO      | Federated MySQL storage engine                                 |
| MRG_MYISAM | YES     | Collection of identical MyISAM tables                          |
| ISAM       | NO      | Obsolete storage engine                                        |
+------------+---------+----------------------------------------------------------------+
12 rows in set, 1 warning (0.00 sec)


thank you verry much xander

PS. Sorry for rating your post wrong, will give you credits in your next reply, your help is much appriciated...


Top
 Profile  
 
 Post subject:
PostPosted: Fri Apr 13, 2007 5:29 am 
Regular
Regular

Joined: Thu Dec 22, 2005 7:47 am
Posts: 62
Location: Czech Republic
well, not hunger for credits, but if you offer it freely ... :-).

the set up is quite correct. I assume, you have created the innodb file, as shown in http://dev.mysql.com/doc/refman/5.0/en/innodb-configuration.html and set it up (ie.
Code:
innodb_data_file_path=/path/to/innodb/ibdata1:50M
)?

The problem that troubles you is strange, because as i said -- i have some linux and win machines, windows all innodb, linux is innodb/myisam mixture (created with the scripts shown above) and i have no problems with that. i use the connection properties as described in one of my previous posts (you specify the engine in your dialect -- i do not) and it works out of the box.

m.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Apr 13, 2007 5:52 am 
Newbie

Joined: Thu Mar 29, 2007 9:07 am
Posts: 7
mar wrote:
The set up is quite correct. I assume, you have created the innodb file, as shown in http://dev.mysql.com/doc/refman/5.0/en/innodb-configuration.html and ?

As far i can see yes.... (the innoDB part of my.cnf)
Code:
# the following is the InnoDB configuration
# if you wish to disable innodb instead
# uncomment just the next line
#skip-innodb
#
# the rest of the innodb config follows:
# don't eat too much memory, we're trying to be safe on 64Mb boxes
# you might want to bump this up a bit on boxes with more RAM
innodb_buffer_pool_size = 16M
# this is the default, increase it if you have lots of tables
innodb_additional_mem_pool_size = 2M
#
# i'd like to use /var/lib/mysql/innodb, but that is seen as a database :-(
# and upstream wants things to be under /var/lib/mysql/, so that's the route
# we have to take for the moment
#innodb_data_home_dir           = /var/lib/mysql/
#innodb_log_arch_dir            = /var/lib/mysql/
#innodb_log_group_home_dir      = /var/lib/mysql/
# you may wish to change this size to be more suitable for your system
# the max is there to avoid run-away growth on your machine
innodb_data_file_path = ibdata1:10M:autoextend:max:128M
# we keep this at around 25% of of innodb_buffer_pool_size
# sensible values range from 1MB to (1/innodb_log_files_in_group*innodb_buffer_pool_size)
innodb_log_file_size = 5M
# this is the default, increase it if you have very large transactions going on
innodb_log_buffer_size = 8M
# this is the default and won't hurt you
# you shouldn't need to tweak it
set-variable = innodb_log_files_in_group=2
# see the innodb config docs, the other options are not always safe
innodb_flush_log_at_trx_commit = 1
innodb_lock_wait_timeout = 50


The path /var/lib/mysql contains a file named ibdata1 which is recently changed.. so must be the one mysql uses.

The main reason why i want to use innodb is the ability to lock tables while commiting changes. I bet thats the main trade off when i switch to use myISAM?


Top
 Profile  
 
 Post subject:
PostPosted: Fri Apr 13, 2007 7:27 am 
Regular
Regular

Joined: Thu Dec 22, 2005 7:47 am
Posts: 62
Location: Czech Republic
Ok, as far as i know, i see no reason the set up should not be working (mine is more or less the same). Lets look at the MySQL part.

i have mysql-server 5.0.38, i restarted my server, put all the innodb options to defaults:

Code:
[mysqld]
default-storage-engine = innodb
default-table-type = innodb
innodb_data_file_path=ibdata1:10M:autoextend


and i regenerated the database on linux with dialect set to both possibilites:

Code:
db.dialect = org.hibernate.dialect.MySQLInnoDBDialect

Code:
db.dialect = org.hibernate.dialect.MySQLDialect


both were just fine, schemaexport, populate, junit (the app was working).

If i connect to the server using mysql command line client:

Code:
mysql> use facicash;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
mysql> describe users;
+----------------------+--------------+------+-----+---------+----------------+
| Field                | Type         | Null | Key | Default | Extra          |
+----------------------+--------------+------+-----+---------+----------------+
| user_id              | bigint(20)   | NO   | PRI | NULL    | auto_increment |
| ctime                | datetime     | NO   |     |         |                |
| mtime                | datetime     | NO   |     |         |                |
| creator              | bigint(20)   | YES  | MUL | NULL    |                |
| owner                | bigint(20)   | YES  | MUL | NULL    |                |
| login_name           | varchar(40)  | NO   | UNI |         |                |
| passwd               | varchar(255) | NO   |     |         |                |
| activex              | bit(1)       | NO   |     |         |                |
| organization_unit_id | bigint(20)   | NO   | MUL |         |                |
+----------------------+--------------+------+-----+---------+----------------+
9 rows in set (0.02 sec)

mysql> describe USERS;
ERROR 1146 (42S02): Table 'facicash.USERS' doesn't exist


I got the same error, only that my databases tables are all lowercase, so i never encountered the situation you speak of -- sorry for mystifying, i should make myself sure before i had stated that -- i use only lower case in my code and linux as my primary development platform.

if i run the mysqldump command, i got the same output, except for right (small_case) table names. changing the case of *.frm files did not help, though changing it from small_case to UPPER_CASE causes the app to stop working.

- - - -

To sum up:

if you created the database on windows, then using mysqldump and imported the db to linux, the case problem can occur.

Only thing i can think of is to use sed/perl/python script to lower/UPPER case the table names as required and unify the access to database objects, using only the desired case in your code (as i dont believe hibernate changes the case you use).

Using small_case on linux makes me happy on linux box and also on windows box, but i admit, that i only traansfer files from linux -> win, so from case sensitive system to case insensitive one (probably the opposite of what you are doing?).

Back to previous posts:

Quote:
Quote:
if you database is "small_case" you should bnot connect to it as "SMALL_CASE", the same for tables.

i understand that... but this is done by hibernate... i just dont understand why hibernate does that..


I believe you should use the same case even for InnoDB, because InnoDB still uses the *.frm files on linux (case sensitive) filesystem.

I think it can be considered as MySQL issue (even bug? (i believe SQL is case insensitive in table names)).

regards, m.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Apr 13, 2007 7:47 am 
Newbie

Joined: Thu Mar 29, 2007 9:07 am
Posts: 7
mar wrote:

I believe you should use the same case even for InnoDB, because InnoDB still uses the *.frm files on linux (case sensitive) filesystem.



where do you see case diffrences?

just to be sure you understand the situation:
I wrote the simple program as showed in my first post. In those files all cases are equal. When I run the program using a windows-mysql, it runs nicely. When i run the program using a linux box, it doesn't create some of the table names or database name using the correct cases.

I belive it's not a mysql bug when i look into all SQL statements that are produced by hibernate i see the same case diffrence.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Apr 13, 2007 8:38 am 
Regular
Regular

Joined: Thu Dec 22, 2005 7:47 am
Posts: 62
Location: Czech Republic
ad case change:

we both have the same (linux) server set up. i just tried this:

1. i assured myself, that hibernate keeps the case for me _exactly_ as written in code (*.hbm.xml files), so does the MySQL (in mysql client and mysqldump).

2. changing the case (after database was generated) caused the same error for me

3. i made an assumption, that you created the db on win, mysqldump it, put onto linux box (meanwhile the case of the tables was changed somehow), and then you get the error.

I made that assumption, cause i tried to figure out how the case change could be done (and because i was able to encounter the same error, once doing some tests, see bellow).

ad more info of what i have done:

Generating the database on my set up keeps _exact_ case i use in *.hbm.xml files. If i change *.hbm.xml files and/or *.frm files i got the error. In other words -- once the db is set up and you make change:

a) user->USER in hbm.xml files -- hibernate starts to use 'USER' instead of 'user', of course, there is no such a table

b) user->USER in the datanase -- hibernate still uses 'user', but the db table is 'USER', again, no such user

once the case was changed on either side, it stopped working. without any intervention from me, it just worked (tables from *.hbm.xml files kept the exact case, mysql kept the exact case and hql and criteria queries use the *.hbm.xml files to construct the query)

ad mysql issue:

hence i believe, the user table == USER table, no matter whether you use from user or from USER, it is not a problem on Oracle, HSQLDB, why the hell on MySQL?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 19, 2007 9:33 am 
Newbie

Joined: Thu Mar 29, 2007 9:07 am
Posts: 7
I found the cause of the problem. It has something do to with DatabaseMetaData which is provided by each JDBC connector.

Hibernate respects the case properties of each database. Those are implemented in DatabaseMetaData's functions:
- storesUpperCaseQuotedIdentifiers() : boolean
- storesLowerCaseQuotedIdentifiers() : boolean
- storesMixedCaseQuotedIdentifiers() : boolean
- (and more...)

For mySQL this means...
..if ran on MS Windows: lower case
..if ran on Linux: upper case

Because i created my database in Linux with lowercase, the hbm2ddl module of hibernate can't get the database layout of, this means that any schema update can't be processed because it tries to find the database in capital characters.

The solution to this problem is that the database should be created using capital characters and also be mentioned using capital characters in the connection string.

I might file a bug about this on mysql and suggest that they should change either the mysql (Linux) database to not accept lower case databases and tables. Or they should change the meta data (and all code involving this matter) in their JDBC driver.

Probably Hibernate should case the connection string according to the DatabaseMetaData's properties of each JDBC.

Thanx mar for searching and helping... if you want more information please post it here....


greetings Xander


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 19, 2007 9:53 am 
Regular
Regular

Joined: Thu Dec 22, 2005 7:47 am
Posts: 62
Location: Czech Republic
ok, thanks for posting your 'findings'.

as i experienced -- the hibernate preserves the case for me on linux as well as on windows (i use my simple script to produce the database creation commands -- same on both platforms -- all lowercase).

your investigation was much more 'in-depth' one -- if you could post it here, i would gladly look at it, cause i also use MySQL and Hibernate on both platforms.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 14 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.