hibernate Schema export happens twice -
a friend , develop web application conferences management uses hibernate (school project). when start application db (mysql) tables created data. until worked well, yesterday friend entered functionality assign participant conference, , whenever try use following (cleared console before action):
hibernate: select conference0_.conferenceid conferen1_2_, conference0_.active active2_, conference0_.description descript3_2_, conference0_.enddate enddate2_, conference0_.location_name location7_2_, conference0_.name name2_, conference0_.startdate startdate2_ test.conferences conference0_ conference0_.name=? hibernate: select location0_.name name5_0_, location0_.active active5_0_, location0_.address address5_0_, location0_.contactname contactn4_5_0_, location0_.locationid locationid5_0_, location0_.maxcapacity maxcapac6_5_0_, location0_.phone1 phone7_5_0_, location0_.phone2 phone8_5_0_ test.location location0_ location0_.name=? hibernate: select user0_.userid userid1_, user0_.active active1_, user0_.admin admin1_, user0_.company_companyid company13_1_, user0_.email email1_, user0_.lastlogin lastlogin1_, user0_.name name1_, user0_.pasportid pasportid1_, user0_.password password1_, user0_.phone1 phone9_1_, user0_.phone2 phone10_1_, user0_.salt salt1_, user0_.username username1_ test.users user0_ user0_.username=? hibernate: select company0_.companyid companyid0_0_, company0_.active active0_0_, company0_.companytype companyt3_0_0_, company0_.name name0_0_ test.company company0_ company0_.companyid=? hibernate: alter table test.conferences drop foreign key fkc0dcf2b7133695cf 04/06/2012 22:42:32 org.hibernate.tool.hbm2ddl.schemaexport execute info: hhh000227: running hbm2ddl schema export hibernate: alter table test.conferences_participants drop foreign key fk5d9c90484daaae9b hibernate: alter table test.conferences_participants drop foreign key fk5d9c9048751ca8aa hibernate: alter table test.conferences_users drop foreign key fk7eaae2604daaae9b hibernate: alter table test.conferences_users drop foreign key fk7eaae260751ca8aa hibernate: alter table test.users drop foreign key fk4e39de8b5d743ae hibernate: drop table if exists test.conferences hibernate: drop table if exists test.company hibernate: drop table if exists test.conferences_participants hibernate: drop table if exists test.conferences_users 04/06/2012 22:42:33 org.hibernate.tool.hbm2ddl.schemaexport execute info: hhh000230: schema export complete 04/06/2012 22:42:33 org.hibernate.cfg.configuration configure info: hhh000043: configuring resource: /hibernate.cfg.xml 04/06/2012 22:42:33 org.hibernate.cfg.configuration getconfigurationinputstream info: hhh000040: configuration resource: /hibernate.cfg.xml 04/06/2012 22:42:33 org.hibernate.cfg.configuration doconfigure info: hhh000041: configured sessionfactory: null 04/06/2012 22:42:33 org.hibernate.mapping.rootclass checkcompositeidentifier warn: hhh000038: composite-id class not override equals(): model.conferencesparticipants 04/06/2012 22:42:33 org.hibernate.mapping.rootclass checkcompositeidentifier warn: hhh000039: composite-id class not override hashcode(): model.conferencesparticipants 04/06/2012 22:42:33 org.hibernate.mapping.rootclass checkcompositeidentifier warn: hhh000038: composite-id class not override equals(): model.conferencesusers 04/06/2012 22:42:33 org.hibernate.mapping.rootclass checkcompositeidentifier warn: hhh000039: composite-id class not override hashcode(): model.conferencesusers 04/06/2012 22:42:33 org.hibernate.service.jdbc.connections.internal.drivermanagerconnectionproviderimpl configure info: hhh000402: using hibernate built-in connection pool (not production use!) 04/06/2012 22:42:33 org.hibernate.service.jdbc.connections.internal.drivermanagerconnectionproviderimpl configure info: hhh000115: hibernate connection pool size: 1 04/06/2012 22:42:33 org.hibernate.service.jdbc.connections.internal.drivermanagerconnectionproviderimpl configure info: hhh000006: autocommit mode: false 04/06/2012 22:42:33 org.hibernate.service.jdbc.connections.internal.drivermanagerconnectionproviderimpl configure info: hhh000401: using driver [com.mysql.jdbc.driver] @ url [jdbc:mysql://localhost:3306/test] 04/06/2012 22:42:33 org.hibernate.service.jdbc.connections.internal.drivermanagerconnectionproviderimpl configure info: hhh000046: connection properties: {user=root, password=****} hibernate: drop table if exists test.location hibernate: drop table if exists test.users 04/06/2012 22:42:34 org.hibernate.dialect.dialect <init> info: hhh000400: using dialect: org.hibernate.dialect.mysql5dialect 04/06/2012 22:42:34 org.hibernate.engine.transaction.internal.transactionfactoryinitiator initiateservice info: hhh000399: using default transaction strategy (direct jdbc transactions) 04/06/2012 22:42:34 org.hibernate.hql.internal.ast.astquerytranslatorfactory <init> info: hhh000397: using astquerytranslatorfactory 04/06/2012 22:42:34 org.hibernate.tool.hbm2ddl.schemaexport execute info: hhh000227: running hbm2ddl schema export hibernate: alter table test.conferences drop foreign key fkc0dcf2b7133695cf 04/06/2012 22:42:34 org.hibernate.tool.hbm2ddl.schemaexport perform error: hhh000389: unsuccessful: alter table test.conferences drop foreign key fkc0dcf2b7133695cf 04/06/2012 22:42:34 org.hibernate.tool.hbm2ddl.schemaexport perform error: table 'test.conferences' doesn't exist 04/06/2012 22:42:34 org.hibernate.tool.hbm2ddl.schemaexport perform error: hhh000389: unsuccessful: alter table test.conferences_participants drop foreign key fk5d9c90484daaae9b 04/06/2012 22:42:34 org.hibernate.tool.hbm2ddl.schemaexport perform error: table 'test.conferences_participants' doesn't exist hibernate: alter table test.conferences_participants drop foreign key fk5d9c90484daaae9b hibernate: alter table test.conferences_participants drop foreign key fk5d9c9048751ca8aa 04/06/2012 22:42:34 org.hibernate.tool.hbm2ddl.schemaexport perform error: hhh000389: unsuccessful: alter table test.conferences_participants drop foreign key fk5d9c9048751ca8aa 04/06/2012 22:42:34 org.hibernate.tool.hbm2ddl.schemaexport perform error: table 'test.conferences_participants' doesn't exist 04/06/2012 22:42:34 org.hibernate.tool.hbm2ddl.schemaexport perform error: hhh000389: unsuccessful: alter table test.conferences_users drop foreign key fk7eaae2604daaae9b 04/06/2012 22:42:34 org.hibernate.tool.hbm2ddl.schemaexport perform error: table 'test.conferences_users' doesn't exist 04/06/2012 22:42:34 org.hibernate.tool.hbm2ddl.schemaexport perform error: hhh000389: unsuccessful: alter table test.conferences_users drop foreign key fk7eaae260751ca8aa 04/06/2012 22:42:34 org.hibernate.tool.hbm2ddl.schemaexport perform error: table 'test.conferences_users' doesn't exist 04/06/2012 22:42:34 org.hibernate.tool.hbm2ddl.schemaexport perform error: hhh000389: unsuccessful: alter table test.users drop foreign key fk4e39de8b5d743ae 04/06/2012 22:42:34 org.hibernate.tool.hbm2ddl.schemaexport perform error: table 'test.users' doesn't exist hibernate: alter table test.conferences_users drop foreign key fk7eaae2604daaae9b hibernate: alter table test.conferences_users drop foreign key fk7eaae260751ca8aa hibernate: alter table test.users drop foreign key fk4e39de8b5d743ae hibernate: drop table if exists test.conferences hibernate: drop table if exists test.company hibernate: drop table if exists test.conferences_participants hibernate: drop table if exists test.conferences_users hibernate: drop table if exists test.location hibernate: drop table if exists test.users hibernate: create table test.conferences ( conferenceid bigint not null, active boolean not null, description varchar(255), enddate datetime, name varchar(255), startdate datetime, location_name varchar(255), primary key (conferenceid) ) hibernate: create table test.company ( companyid bigint not null, active boolean not null, companytype varchar(255), name varchar(255), primary key (companyid) ) hibernate: create table test.conferences_participants ( date datetime not null, user_userid bigint not null, conference_conferenceid bigint not null, primary key (user_userid, date, conference_conferenceid), unique (user_userid), unique (conference_conferenceid) ) hibernate: create table test.conferences_users ( attendancestatus integer, notifiedbymail boolean not null, userrole integer not null, user_userid bigint not null, conference_conferenceid bigint not null, primary key (user_userid, conference_conferenceid), unique (user_userid), unique (conference_conferenceid) ) hibernate: create table test.location ( name varchar(255) not null, active boolean not null, address varchar(255), contactname varchar(255), locationid bigint not null, maxcapacity integer not null, phone1 varchar(255), phone2 varchar(255), primary key (name) ) hibernate: create table test.users ( userid bigint not null, active boolean not null, admin boolean not null, email varchar(255), lastlogin datetime, name varchar(255), pasportid varchar(255), password varchar(255), phone1 varchar(255), phone2 varchar(255), salt varchar(255), username varchar(255), company_companyid bigint, primary key (userid) ) hibernate: alter table test.conferences add index fkc0dcf2b7133695cf (location_name), add constraint fkc0dcf2b7133695cf foreign key (location_name) references test.location (name) hibernate: alter table test.conferences_participants add index fk5d9c90484daaae9b (conference_conferenceid), add constraint fk5d9c90484daaae9b foreign key (conference_conferenceid) references test.conferences (conferenceid) hibernate: alter table test.conferences_participants add index fk5d9c9048751ca8aa (user_userid), add constraint fk5d9c9048751ca8aa foreign key (user_userid) references test.users (userid) hibernate: alter table test.conferences_users add index fk7eaae2604daaae9b (conference_conferenceid), add constraint fk7eaae2604daaae9b foreign key (conference_conferenceid) references test.conferences (conferenceid) hibernate: alter table test.conferences_users add index fk7eaae260751ca8aa (user_userid), add constraint fk7eaae260751ca8aa foreign key (user_userid) references test.users (userid) hibernate: alter table test.users add index fk4e39de8b5d743ae (company_companyid), add constraint fk4e39de8b5d743ae foreign key (company_companyid) references test.company (companyid) hibernate: select conference0_.user_userid user4_16_0_, conference0_.conference_conferenceid conference5_16_0_, conference0_.attendancestatus attendan1_16_0_, conference0_.notifiedbymail notified2_16_0_, conference0_.userrole userrole16_0_ test.conferences_users conference0_ conference0_.user_userid=? , conference0_.conference_conferenceid=? 04/06/2012 22:42:36 org.hibernate.tool.hbm2ddl.schemaexport execute info: hhh000230: schema export complete hibernate: insert test.conferences_users (attendancestatus, notifiedbymail, userrole, user_userid, conference_conferenceid) values (?, ?, ?, ?, ?) 04/06/2012 22:42:36 org.hibernate.engine.jdbc.spi.sqlexceptionhelper logexceptions warn: sql error: 1048, sqlstate: 23000 04/06/2012 22:42:36 org.hibernate.engine.jdbc.spi.sqlexceptionhelper logexceptions error: column 'user_userid' cannot null 04/06/2012 22:42:37 org.apache.catalina.core.standardwrappervalve invoke severe: servlet.service() servlet [conferenceservlet] in context path [/conf4u] threw exception org.hibernate.transactionexception: nested transactions not supported @ org.hibernate.engine.transaction.spi.abstracttransactionimpl.begin(abstracttransactionimpl.java:152) @ org.hibernate.internal.sessionimpl.begintransaction(sessionimpl.java:1396) @ sun.reflect.generatedmethodaccessor39.invoke(unknown source) @ sun.reflect.delegatingmethodaccessorimpl.invoke(unknown source) @ java.lang.reflect.method.invoke(unknown source) @ org.hibernate.context.internal.threadlocalsessioncontext$transactionprotectionwrapper.invoke(threadlocalsessioncontext.java:352) @ $proxy14.begintransaction(unknown source) @ daos.conferencedao.isconferencenameexists(conferencedao.java:129) @ servlets.conferenceservlet.assignuser(conferenceservlet.java:282) @ servlets.conferenceservlet.processrequest(conferenceservlet.java:76) @ servlets.conferenceservlet.dopost(conferenceservlet.java:432) @ javax.servlet.http.httpservlet.service(httpservlet.java:641) @ javax.servlet.http.httpservlet.service(httpservlet.java:722) @ org.apache.catalina.core.applicationfilterchain.internaldofilter(applicationfilterchain.java:305) @ org.apache.catalina.core.applicationfilterchain.dofilter(applicationfilterchain.java:210) @ org.apache.catalina.core.standardwrappervalve.invoke(standardwrappervalve.java:224) @ org.apache.catalina.core.standardcontextvalve.invoke(standardcontextvalve.java:169) @ org.apache.catalina.core.standardhostvalve.invoke(standardhostvalve.java:168) @ org.apache.catalina.valves.errorreportvalve.invoke(errorreportvalve.java:98) @ org.apache.catalina.valves.accesslogvalve.invoke(accesslogvalve.java:927) @ org.apache.catalina.core.standardenginevalve.invoke(standardenginevalve.java:118) @ org.apache.catalina.connector.coyoteadapter.service(coyoteadapter.java:407) @ org.apache.coyote.http11.abstracthttp11processor.process(abstracthttp11processor.java:987) @ org.apache.coyote.abstractprotocol$abstractconnectionhandler.process(abstractprotocol.java:579) @ org.apache.tomcat.util.net.jioendpoint$socketprocessor.run(jioendpoint.java:309) @ java.util.concurrent.threadpoolexecutor$worker.runtask(unknown source) @ java.util.concurrent.threadpoolexecutor$worker.run(unknown source) @ java.lang.thread.run(unknown source) from reason seems it's running hbm2ddl schema export again, assume causes problem?
the thing doesn't happen him, , we're checked out same version.
i have no idea might problem.
the hibernate configuration:
<hibernate-configuration> <session-factory> <property name="connection.url">jdbc:mysql://localhost:3306/test</property> <property name="connection.username">root</property> <property name="connection.password">root</property> <property name="connection.driver_class">com.mysql.jdbc.driver</property> <property name="hibernate.default_schema">test</property> <property name="dialect">org.hibernate.dialect.mysql5dialect</property> <property name="show_sql">true</property> <property name="format_sql">true</property> <property name="hbm2ddl.auto">create-drop</property> <!-- jdbc connection pool (use built-in) --> <property name="connection.pool_size">1</property> <property name="current_session_context_class">thread</property> <!-- mapping files go here.... --> <mapping class="model.company" /> <mapping class="model.user" /> <mapping class="model.conference" /> <mapping class="model.conferencesparticipants" /> <mapping class="model.conferencesusers" /> <mapping class="model.location" /> </session-factory> </hibernate-configuration> the function being run assign action:
public void assignusertoconference(conferencesusers cu){ session session = hibernateutil.getsessionfactory().getcurrentsession(); try { session.begintransaction(); session.save(cu); session.gettransaction().commit(); } catch (runtimeexception e) { session.gettransaction().rollback(); throw e; } } hibernateutil :
public class hibernateutil { private static sessionfactory sessionfactory = configuresessionfactory(); private static serviceregistry serviceregistry; private static sessionfactory configuresessionfactory() throws hibernateexception { configuration configuration = new configuration(); configuration.configure(); serviceregistry = new serviceregistrybuilder().applysettings(configuration.getproperties()).buildserviceregistry(); sessionfactory = configuration.buildsessionfactory(serviceregistry); return sessionfactory; } /** * session database * @return */ public static sessionfactory getsessionfactory() { if(sessionfactory== null){ sessionfactory = configuresessionfactory(); } return sessionfactory; } /** * close current session database */ public static void closesession(){ sessionfactory.close(); } } i'd appreciate this. thanks!
in logs see theres null value:
04/06/2012 22:42:36 org.hibernate.engine.jdbc.spi.sqlexceptionhelper logexceptions warn: sql error: 1048, sqlstate: 23000 04/06/2012 22:42:36 org.hibernate.engine.jdbc.spi.sqlexceptionhelper logexceptions error: column 'user_userid' cannot null btw, operating systems , friend use? i'm asking 'cause i'm investigating similar problem.
Comments
Post a Comment