Hibernate Dropping database tables

General support questions
Post Reply
jamendozaslmc
Posts: 5
Joined: 2017/05/10 02:58:13

Hibernate Dropping database tables

Post by jamendozaslmc » 2017/05/11 04:24:41

Hi to all,

We would like to ask for everyone's help on how we can compare the difference in CENTOS 6.9 configuration, as our systems behave differently on two(2) different server, we did an update of both servers but still no luck. One of the server works fine, but the other is dropping all the tables and recreate it. (see attached logs)

We are using a customized hibernate with version 3.2.6.
Jettty 9.2.17 and running on Java 1.7_80 JVM (Oracle)

We suspect a difference in configuration but unable to prove it, both are running under VMware 6.0.0 (configuration are the same for VM Guest)

Your comments, review and help are highly appreciated.

We are one of the company that uses CENTOS for production systems.

Thank you and
Attachments
CentOS_Comparison.rar
CSV format
(8.95 KiB) Downloaded 101 times
DroppingTables.log
(2.07 KiB) Downloaded 121 times
NotDroppingTables.log
(1.59 KiB) Downloaded 107 times

aks
Posts: 3073
Joined: 2014/09/20 11:22:14

Re: Hibernate Dropping database tables

Post by aks » 2017/05/11 16:53:37

In my opinion this is not an OS layer issue. This is most likely a hibernate problem (so check you persistence/hiberate files).
The DroppingTables.log suggests to me that the tables exist and thus are not being created (which is often an error condition in SQL). There's nothing to suggest they are actually being dropped.
Also get off Java 7. It's way EOL, you should really be on Java 8 by now.

jamendozaslmc
Posts: 5
Joined: 2017/05/10 02:58:13

Re: Hibernate Dropping database tables

Post by jamendozaslmc » 2017/05/12 08:28:07

Thanks we will look in to, we just cannot thought of any reasons why the same application behaves differently on a servers that has the same OS kernel and patches and libraries.

Thanks again.

aks
Posts: 3073
Joined: 2014/09/20 11:22:14

Re: Hibernate Dropping database tables

Post by aks » 2017/05/12 22:51:42

And exact same application configuration? How do you know? Think about it. I not saying it's your fault per se, but you have different application layer problems when the OS binaries (NOTE: not configurations) are the same. So if it's not on the app, look at the DB config (off hand can't think of any DB config that would default to destroy data).

jamendozaslmc
Posts: 5
Joined: 2017/05/10 02:58:13

Re: Hibernate Dropping database tables

Post by jamendozaslmc » 2017/05/15 03:14:06

Hi aks

Yes i am confident that they are the same, we just used a tar balled jetty with pre configured system settings, and connected to same database server.
I just wonder if we missed some configurations inside the operating system. all we can do is clone that server in order to continue with testing until production. Hope we can have some way to check configuration files on the OS.

Thank you so much.

aks
Posts: 3073
Joined: 2014/09/20 11:22:14

Re: Hibernate Dropping database tables

Post by aks » 2017/05/15 16:26:48

Only things I can think of are:

1) DROP TABLE IF EXISTS '<table_name>' SQL command.
2) A very clever trigger/stored procedure that empties tables on condition(s).
3) The create-drop or create configuration in Hibernate. Something like <property name="hibernate.hbm2ddl.auto">create</property> will create the tables, but if the tables are already created then it will drop all the tables and again create tables (which means you'd loose data). Also there's the create-drop option which has a similar effect. If you have that on, try switching to the update property (substitute update or create in the above example).

jamendozaslmc
Posts: 5
Joined: 2017/05/10 02:58:13

Re: Hibernate Dropping database tables

Post by jamendozaslmc » 2017/05/16 01:31:48

Hi Aks,

We already did those configuration but still does not work on the other server.

Also the application behaves differently on other servers, i have tested it 3x. 1 server reading hibernate.properties instead of hibernate.cfg.xml (which is the correct one or working) and the other one is reading the hibernate.cfg.xml instead of hibernate.properties (which is wrong).

Is there any config in the operating system caused this behavior?

Thank you

jamendozaslmc
Posts: 5
Joined: 2017/05/10 02:58:13

Re: Hibernate Dropping database tables

Post by jamendozaslmc » 2017/05/16 01:44:30

Regarding our customized hibernate version 3.2.6. see the configuration made to each application hibernate files

hibernate.properties

hibernate.dialect=org.hibernate.dialect.Oracle10gDialect
hibernate.query.substitutions=true 'Y', false 'N'
hibernate.cache.use_second_level_cache=true
hibernate.cache.provider_class=net.sf.ehcache.hibernate.SingletonEhCacheProvider
net.sf.ehcache.configurationResourceName=/ehcache.xml
hibernate.show_sql=true
hibernate.format_sql=true
hibernate.use_sql_comments=false
hibernate.jdbc.batch_size=50
#hibernate.jdbc.factory_class=net.bull.javamelody.HibernateBatcherFactory
hibernate.hbm2ddl.auto=none

jdbc-oracle.properties

jdbc.driverClassName=oracle.jdbc.OracleDriver
hibernate.dialect=org.hibernate.dialect.Oracle10gDialect
hibernate.hbm2ddl.auto=none

hibernate.cfg.xml

<property name="hibernate.connection.driver_class">oracle.jdbc.driver.OracleDriver</property>
<property name="hibernate.connection.url">jdbc:oracle:thin:@192.168.x.x:1521:xxxxdevdb</property>
<property name="hibernate.connection.username">hcstest</property>
<property name="hibernate.connection.password">hcstest</property>
<property name="hibernate.dialect">org.hibernate.dialect.Oracle10gDialect</property>
<property name="hibernate.default_schema">hcstest</property>
<property name="show_sql">true</property>
<property name="hbm2ddl.auto">none</property>

server.log

12 May 2017 10:07:42,975 WARN [main] CustomEditorConfigurer.postProcessBeanFactory(187) | Passing PropertyEditor instances into CustomEditorConfigurer is deprecated: use PropertyEditorRegistrars or PropertyEditor class names instead. Offending key [java.util.Date; offending editor instance: org.springframework.beans.propertyeditors.CustomDateEditor@630f9225

12 May 2017 10:08:19,375 ERROR [main] SchemaExport.create(274) | Unsuccessful: create table hcstest.CTRL_APP (ID number(19,0) not null, APP_NAME varchar2(20 char) not null unique, primary key (ID), unique (APP_NAME))
12 May 2017 10:08:19,376 ERROR [main] SchemaExport.create(275) | ORA-02261: such unique or primary key already exists in the table

12 May 2017 10:08:19,390 ERROR [main] SchemaExport.create(274) | Unsuccessful: create table hcstest.CTRL_APP_USER (id number(19,0) not null, ACCOUNT_EXPIRED char(1 char), ACCOUNT_LOCKED char(1 char), CREATED_BY varchar2(50 char), CREATED_DATETIME timestamp, UPDATED_BY varchar2(50 char), UPDATED_DATETIME timestamp, CREDENTIALS_EXPIRED char(1 char), EMAIL varchar2(70 char), ACCOUNT_ENABLED char(1 char), PASSWORD varchar2(255 char), PASSWORD_EXPIRED char(1 char), PASSWORD_HINT varchar2(255 char), PERMISSIONS varchar2(60 char), USERNAME varchar2(50 char) not null unique, version number(10,0), ORGSTRUCTURE varchar2(5 char), EMPLOYEE varchar2(10 char), DOCTOR varchar2(10 char), SECTION varchar2(5 char), primary key (id), unique (USERNAME))

Everyone's help is very appreciated.

Thank you

aks
Posts: 3073
Joined: 2014/09/20 11:22:14

Re: Hibernate Dropping database tables

Post by aks » 2017/05/16 17:35:24

Is there any config in the operating system caused this behavior?
No, not by default - and that is validated by the fact that it works on other servers.

So you're using:
hibernate.hbm2ddl.auto=none
AFAIK, that's supposed to disable it (https://docs.jboss.org/hibernate/orm/5. ... ons-hbmddl), in hibernate 5 (I think it didn't in older versions). But then we see in your log:
ERROR [main] SchemaExport.create(274) | Unsuccessful: create table hcstest.CTRL_APP (ID number(19,0) not null, APP_NAME varchar2(20 char) not null unique, primary key (ID), unique (APP_NAME))
12 May 2017 10:08:19,376 ERROR [main] SchemaExport.create(275) | ORA-02261: such unique or primary key already exists in the table
Schema validation is happening. SchemaExport (https://docs.jboss.org/hibernate/orm/3. ... xport.html) does just that (along with a drop method). So I guess none ain't working (or it's being overwritten somewhere).

I don't use that in production, I use Flyway and it does work quite well.

alterseiba
Posts: 3
Joined: 2017/05/26 09:37:09

Re: Hibernate Dropping database tables

Post by alterseiba » 2017/06/30 03:41:31

Hi,

I had the same problem with the different behavior of two servers with Centos 6.9 OS.
I'm using Spring Maven project using hibernate 3.6.10.Final and Jetty 9.2.17 and running on Java 1.7_80 JVM (Oracle).
In my local environment Windows 10 and Centos 6.9(Server 1) it works perfectly with the same sha1 of the war file. But when I deploy to Centos 6.9(Server 2) it gives me an error in dropping table even my configuration hibernate.hbm2ddl.auto is off (omitting to hibernate.hbm2ddl.auto defaults to hibernate not doing anything). https://docs.jboss.org/hibernate/orm/5. ... /ch03.html

hibernate.dialect=org.hibernate.dialect.Oracle10gDialect
hibernate.query.substitutions=true 'Y', false 'N'
hibernate.cache.use_second_level_cache=true
hibernate.cache.provider_class=net.sf.ehcache.hibernate.SingletonEhCacheProvider
net.sf.ehcache.configurationResourceName=/ehcache.xml
hibernate.show_sql=true
hibernate.format_sql=true
hibernate.use_sql_comments=false
hibernate.jdbc.batch_size=50

I really appreciate if anyone can suggest me what is causing this exception and how can I fix this?

Thanks in Advance.

Post Reply