1

友人と私は、休止状態 (学校のプロジェクト) を使用する会議管理用の Web アプリケーションを開発しています。アプリケーションを起動すると、データベース (mysql) テーブルがいくつかのデータで作成されます。最近まではすべてうまく機能していましたが、昨日、友人が参加者を会議に割り当てる機能を入力しました。それを使用しようとすると、次のようになります (このアクションの直前にコンソールをクリアします)。

Hibernate: 
    select
        conference0_.conferenceId as conferen1_2_,
        conference0_.active as active2_,
        conference0_.description as descript3_2_,
        conference0_.endDate as endDate2_,
        conference0_.location_name as location7_2_,
        conference0_.name as name2_,
        conference0_.startDate as startDate2_ 
    from
        test.CONFERENCES conference0_ 
    where
        conference0_.name=?
Hibernate: 
    select
        location0_.name as name5_0_,
        location0_.active as active5_0_,
        location0_.address as address5_0_,
        location0_.contactName as contactN4_5_0_,
        location0_.locationId as locationId5_0_,
        location0_.maxCapacity as maxCapac6_5_0_,
        location0_.phone1 as phone7_5_0_,
        location0_.phone2 as phone8_5_0_ 
    from
        test.LOCATION location0_ 
    where
        location0_.name=?
Hibernate: 
    select
        user0_.userId as userId1_,
        user0_.active as active1_,
        user0_.admin as admin1_,
        user0_.company_companyID as company13_1_,
        user0_.email as email1_,
        user0_.lastLogin as lastLogin1_,
        user0_.name as name1_,
        user0_.pasportID as pasportID1_,
        user0_.password as password1_,
        user0_.phone1 as phone9_1_,
        user0_.phone2 as phone10_1_,
        user0_.salt as salt1_,
        user0_.userName as userName1_ 
    from
        test.Users user0_ 
    where
        user0_.userName=?
Hibernate: 
    select
        company0_.companyID as companyID0_0_,
        company0_.active as active0_0_,
        company0_.companyType as companyT3_0_0_,
        company0_.name as name0_0_ 
    from
        test.Company company0_ 
    where
        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 from 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 does not override equals(): model.ConferencesParticipants
04/06/2012 22:42:33 org.hibernate.mapping.RootClass checkCompositeIdentifier
WARN: HHH000039: Composite-id class does not override hashCode(): model.ConferencesParticipants
04/06/2012 22:42:33 org.hibernate.mapping.RootClass checkCompositeIdentifier
WARN: HHH000038: Composite-id class does not override equals(): model.ConferencesUsers
04/06/2012 22:42:33 org.hibernate.mapping.RootClass checkCompositeIdentifier
WARN: HHH000039: Composite-id class does 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 for 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] at 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 as user4_16_0_,
        conference0_.conference_conferenceId as conference5_16_0_,
        conference0_.attendanceStatus as attendan1_16_0_,
        conference0_.notifiedByMail as notified2_16_0_,
        conference0_.userRole as userRole16_0_ 
    from
        test.Conferences_Users conference0_ 
    where
        conference0_.user_userId=? 
        and conference0_.conference_conferenceId=?
04/06/2012 22:42:36 org.hibernate.tool.hbm2ddl.SchemaExport execute
INFO: HHH000230: Schema export complete
Hibernate: 
    insert 
    into
        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 be null
04/06/2012 22:42:37 org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet [ConferenceServlet] in context with path [/conf4u] threw exception
org.hibernate.TransactionException: nested transactions not supported
    at org.hibernate.engine.transaction.spi.AbstractTransactionImpl.begin(AbstractTransactionImpl.java:152)
    at org.hibernate.internal.SessionImpl.beginTransaction(SessionImpl.java:1396)
    at sun.reflect.GeneratedMethodAccessor39.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.hibernate.context.internal.ThreadLocalSessionContext$TransactionProtectionWrapper.invoke(ThreadLocalSessionContext.java:352)
    at $Proxy14.beginTransaction(Unknown Source)
    at daos.ConferenceDao.isConferenceNameExists(ConferenceDao.java:129)
    at servlets.ConferenceServlet.assignUser(ConferenceServlet.java:282)
    at servlets.ConferenceServlet.processRequest(ConferenceServlet.java:76)
    at servlets.ConferenceServlet.doPost(ConferenceServlet.java:432)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:641)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:224)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:169)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98)
    at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:927)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
    at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:987)
    at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:579)
    at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:309)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)

何らかの理由で、hbm2ddl スキーマ エクスポートを再度実行しているように見えますが、これが問題の原因だと思いますか?

問題は、彼には起こらないということです。私たちは同じバージョンでチェックアウトしています。

何が問題なのかわかりません。

休止状態の構成:

<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 the built-in) -->
        <property name="connection.pool_size">1</property>
        <property name="current_session_context_class">thread</property>

        <!-- Mapping files will 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>

割り当てアクションに対して実行されている関数:

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;
}

/**
 * get a session to the database
 * @return
 */
public static SessionFactory getSessionFactory() {
    if(sessionFactory== null){
        sessionFactory = configureSessionFactory();
    }
    return sessionFactory;
}

/**
 * close the current session to the database
 */
public static void closeSession(){
    sessionFactory.close();
}



}

ご協力をお願いいたします。ありがとう!

4

2 に答える 2

0

あなたのログには、null 値があることがわかります。

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 be null

ところで、あなたとあなたの友人はどのオペレーティング システムを使用していますか? 同様の問題を調査しているので、私はそれを求めています。

于 2012-06-22T08:14:11.877 に答える
0

問題が休止状態にないことが判明しました。何らかの理由で、Eclipse で何を試しても、コードはコンパイルされたコードと同期していませんでした。新しいワークスペースを作成することで問題を解決しました。

于 2012-06-23T07:49:09.453 に答える