2016-10-19 11 views
2

У меня довольно простая настройка, где у меня есть UserEntity и соответствующая UserStatisticEntity. Я хочу, чтобы это была однонаправленная связь, где UserEntity содержит ссылку. Пользователь UserStatisticEntity должен сохраняться и удаляться с помощью UserEntity, поскольку я использую CascadeType.PERSIST и REMOVE. Я работаю с Glassfish4 и Eclipselink. В настоящее время я делаю это так:
UserEntity:JPA CascadeType не работает

@Entity 
public class UserEntity extends AdditionalEntityInformation { 
@Id 
@SequenceGenerator(name="seqGenUserId") 
@GeneratedValue(strategy=GenerationType.SEQUENCE,generator="seqGenUserId") 
private long userId; 
@OneToOne(cascade={CascadeType.PERSIST, CascadeType.REMOVE}) 
@JoinColumn(name="STAT_ID", unique=true, nullable=false, updatable=false, insertable=false) 
@Basic(optional=false) 
@Column(nullable=false) 
private UserStatisticEntity stats; 
... 
public UserEntity(String username, String passwordHash, UserStatisticEntity stats) { 
     this.username = username; 
     this.passwordHash = passwordHash; 
     this.stats = stats; 
     this.loggedIn = false; 
    } 
} 

UserStatisticEntity:

@Entity 
public class UserStatisticEntity extends StatisticEntity { 
private static final long serialVersionUID = 1L; 

@Basic(fetch=FetchType.EAGER, optional=true) 
private Date lastLogin; 
} 

Unfortunatly это не работает, когда я настойчив в UserEntity, соответствующая UserStatisticEntity не сохраняется. ?
Что я упускаю (Это, наверное, очень проста и очевидна, но для жизни меня я не вижу его)

Edit: Следующие таблицы были созданы из классов (важные вещи):
UserEntity:

USERID bigint(20) 
STATS longblob 

UserStatisticEntity:

ID bigint(20) 
LASTLOGIN datetime 

следующий код используется для создания двух объектов и сохраняются их.

UserStatisticEntity stats = new UserStatisticEntity(0, 0, 0, null); 
UserEntity u = new UserEntity(username, hashingBean.hashString(password), stats); 
em.persist(u); 

сохраняются из UserEntity работ, но сохраняются не каскадно UserStatisticEntity.
Каротажа, что у меня есть:

2016-10-19T13:00:00.925+0200|Konfiguration: The access type for the persistent class [class de.fh_dortmund.hansen.chat.entity.AdditionalEntityInformation] is set to [FIELD]. 
2016-10-19T13:00:00.935+0200|Konfiguration: The access type for the persistent class [class de.fh_dortmund.hansen.chat.entity.UserEntity] is set to [FIELD]. 
2016-10-19T13:00:00.936+0200|Konfiguration: The access type for the persistent class [class de.fh_dortmund.hansen.chat.entity.StatisticEntity] is set to [FIELD]. 
2016-10-19T13:00:00.937+0200|Konfiguration: The access type for the persistent class [class de.fh_dortmund.hansen.chat.entity.UserStatisticEntity] is set to [FIELD]. 
2016-10-19T13:00:00.937+0200|Konfiguration: The access type for the persistent class [class de.fh_dortmund.hansen.chat.entity.CommonStatisticEntity] is set to [FIELD]. 
2016-10-19T13:00:00.940+0200|Konfiguration: The column name for element [createdAt] is being defaulted to: CREATEDAT. 
2016-10-19T13:00:00.942+0200|Konfiguration: The column name for element [updatedAt] is being defaulted to: UPDATEDAT. 
2016-10-19T13:00:00.942+0200|Konfiguration: The alias name for the entity class [class de.fh_dortmund.hansen.chat.entity.UserEntity] is being defaulted to: UserEntity. 
2016-10-19T13:00:00.942+0200|Konfiguration: The table name for entity [class de.fh_dortmund.hansen.chat.entity.UserEntity] is being defaulted to: USERENTITY. 
2016-10-19T13:00:00.946+0200|Konfiguration: The column name for element [createdAt] is being defaulted to: CREATEDAT. 
2016-10-19T13:00:00.947+0200|Konfiguration: The column name for element [stats] is being defaulted to: STATS. 
2016-10-19T13:00:00.948+0200|Konfiguration: The column name for element [loggedIn] is being defaulted to: LOGGEDIN. 
2016-10-19T13:00:00.948+0200|Konfiguration: The column name for element [userId] is being defaulted to: USERID. 
2016-10-19T13:00:00.948+0200|Konfiguration: The column name for element [passwordHash] is being defaulted to: PASSWORDHASH. 
2016-10-19T13:00:00.949+0200|Konfiguration: The column name for element [username] is being defaulted to: USERNAME. 
2016-10-19T13:00:00.949+0200|Konfiguration: The column name for element [updatedAt] is being defaulted to: UPDATEDAT. 
2016-10-19T13:00:00.949+0200|Konfiguration: The alias name for the entity class [class de.fh_dortmund.hansen.chat.entity.UserStatisticEntity] is being defaulted to: UserStatisticEntity. 
2016-10-19T13:00:00.950+0200|Konfiguration: The alias name for the entity class [class de.fh_dortmund.hansen.chat.entity.StatisticEntity] is being defaulted to: StatisticEntity. 
2016-10-19T13:00:00.950+0200|Konfiguration: The table name for entity [class de.fh_dortmund.hansen.chat.entity.StatisticEntity] is being defaulted to: STATISTICENTITY. 
2016-10-19T13:00:00.950+0200|Konfiguration: The column name for element [createdAt] is being defaulted to: CREATEDAT. 
2016-10-19T13:00:00.951+0200|Konfiguration: The column name for element [logouts] is being defaulted to: LOGOUTS. 
2016-10-19T13:00:00.951+0200|Konfiguration: The column name for element [messages] is being defaulted to: MESSAGES. 
2016-10-19T13:00:00.951+0200|Konfiguration: The column name for element [id] is being defaulted to: ID. 
2016-10-19T13:00:00.952+0200|Konfiguration: The column name for element [logins] is being defaulted to: LOGINS. 
2016-10-19T13:00:00.952+0200|Konfiguration: The column name for element [updatedAt] is being defaulted to: UPDATEDAT. 
2016-10-19T13:00:00.952+0200|Konfiguration: The table name for entity [class de.fh_dortmund.hansen.chat.entity.UserStatisticEntity] is being defaulted to: USERSTATISTICENTITY. 
2016-10-19T13:00:00.952+0200|Konfiguration: The column name for element [lastLogin] is being defaulted to: LASTLOGIN. 
2016-10-19T13:00:00.953+0200|Konfiguration: The column name for element [createdAt] is being defaulted to: CREATEDAT. 
2016-10-19T13:00:00.953+0200|Konfiguration: The column name for element [logouts] is being defaulted to: LOGOUTS. 
2016-10-19T13:00:00.954+0200|Konfiguration: The column name for element [messages] is being defaulted to: MESSAGES. 
2016-10-19T13:00:00.954+0200|Konfiguration: The column name for element [id] is being defaulted to: ID. 
2016-10-19T13:00:00.955+0200|Konfiguration: The column name for element [logins] is being defaulted to: LOGINS. 
2016-10-19T13:00:00.956+0200|Konfiguration: The column name for element [updatedAt] is being defaulted to: UPDATEDAT. 
2016-10-19T13:00:00.956+0200|Konfiguration: The alias name for the entity class [class de.fh_dortmund.hansen.chat.entity.CommonStatisticEntity] is being defaulted to: CommonStatisticEntity. 
2016-10-19T13:00:00.956+0200|Konfiguration: The table name for entity [class de.fh_dortmund.hansen.chat.entity.CommonStatisticEntity] is being defaulted to: COMMONSTATISTICENTITY. 
2016-10-19T13:00:00.956+0200|Konfiguration: The column name for element [createdAt] is being defaulted to: CREATEDAT. 
2016-10-19T13:00:00.957+0200|Konfiguration: The column name for element [logouts] is being defaulted to: LOGOUTS. 
2016-10-19T13:00:00.957+0200|Konfiguration: The column name for element [endDate] is being defaulted to: ENDDATE. 
2016-10-19T13:00:00.957+0200|Konfiguration: The column name for element [messages] is being defaulted to: MESSAGES. 
2016-10-19T13:00:00.957+0200|Konfiguration: The column name for element [id] is being defaulted to: ID. 
2016-10-19T13:00:00.958+0200|Konfiguration: The column name for element [startingDate] is being defaulted to: STARTINGDATE. 
2016-10-19T13:00:00.958+0200|Konfiguration: The column name for element [logins] is being defaulted to: LOGINS. 
2016-10-19T13:00:00.958+0200|Konfiguration: The column name for element [updatedAt] is being defaulted to: UPDATEDAT. 
2016-10-19T13:00:00.958+0200|Konfiguration: The sequence name for the sequence generator named [seqGenStatId] defined on [field id] from [field id] is being defaulted to: seqGenStatId. 
2016-10-19T13:00:00.959+0200|Konfiguration: The sequence name for the sequence generator named [seqGenUserId] defined on [field userId] from [field userId] is being defaulted to: seqGenUserId. 
2016-10-19T13:00:00.960+0200|Feiner: Class [de.fh_dortmund.hansen.chat.entity.UserEntity] registered to be processed by weaver. 
2016-10-19T13:00:00.962+0200|Feiner: Class [de.fh_dortmund.hansen.chat.entity.UserStatisticEntity] registered to be processed by weaver. 
2016-10-19T13:00:00.962+0200|Feiner: Class [de.fh_dortmund.hansen.chat.entity.StatisticEntity] registered to be processed by weaver. 
2016-10-19T13:00:00.962+0200|Feiner: Class [de.fh_dortmund.hansen.chat.entity.CommonStatisticEntity] registered to be processed by weaver. 
2016-10-19T13:00:01.027+0200|Am feinsten: End predeploying Persistence Unit ChatDB; session /file:/D:/glassfish4/glassfish/domains/domain1/eclipseApps/Chat-ear/Chat-ejb_jar/_ChatDB; state Predeployed; factoryCount 1 
2016-10-19T13:00:01.032+0200|Feiner: Canonical Metamodel class [de.fh_dortmund.hansen.chat.entity.StatisticEntity_] not found during initialization. 
2016-10-19T13:00:01.032+0200|Feiner: Canonical Metamodel class [de.fh_dortmund.hansen.chat.entity.CommonStatisticEntity_] not found during initialization. 
2016-10-19T13:00:01.033+0200|Feiner: Canonical Metamodel class [de.fh_dortmund.hansen.chat.entity.UserEntity_] not found during initialization. 
2016-10-19T13:00:01.033+0200|Feiner: Canonical Metamodel class [de.fh_dortmund.hansen.chat.entity.UserStatisticEntity_] not found during initialization. 
2016-10-19T13:00:01.033+0200|Feiner: Canonical Metamodel class [de.fh_dortmund.hansen.chat.entity.AdditionalEntityInformation_] not found during initialization. 
2016-10-19T13:00:01.370+0200|Am feinsten: Begin deploying Persistence Unit ChatDB; session /file:/D:/glassfish4/glassfish/domains/domain1/eclipseApps/Chat-ear/Chat-ejb_jar/_ChatDB; state Predeployed; factoryCount 1 
2016-10-19T13:00:01.374+0200|Am feinsten: Begin weaver class transformer processing class [de/fh_dortmund/hansen/chat/entity/UserEntity]. 
2016-10-19T13:00:01.381+0200|Am feinsten: Weaved change tracking (ChangeTracker) [de/fh_dortmund/hansen/chat/entity/UserEntity]. 
2016-10-19T13:00:01.382+0200|Am feinsten: Weaved fetch groups (FetchGroupTracker) [de/fh_dortmund/hansen/chat/entity/UserEntity]. 
2016-10-19T13:00:01.382+0200|Am feinsten: End weaver class transformer processing class [de/fh_dortmund/hansen/chat/entity/UserEntity]. 
2016-10-19T13:00:01.382+0200|Information: de.fh_dortmund.hansen.chat.entity.UserEntity actually got transformed 
2016-10-19T13:00:01.389+0200|Am feinsten: Begin weaver class transformer processing class [de/fh_dortmund/hansen/chat/entity/AdditionalEntityInformation]. 
2016-10-19T13:00:01.390+0200|Am feinsten: Weaved persistence (PersistenceEntity) [de/fh_dortmund/hansen/chat/entity/AdditionalEntityInformation]. 
2016-10-19T13:00:01.391+0200|Am feinsten: Weaved change tracking (ChangeTracker) [de/fh_dortmund/hansen/chat/entity/AdditionalEntityInformation]. 
2016-10-19T13:00:01.391+0200|Am feinsten: Weaved fetch groups (FetchGroupTracker) [de/fh_dortmund/hansen/chat/entity/AdditionalEntityInformation]. 
2016-10-19T13:00:01.391+0200|Am feinsten: Weaved REST [de/fh_dortmund/hansen/chat/entity/AdditionalEntityInformation]. 
2016-10-19T13:00:01.391+0200|Am feinsten: End weaver class transformer processing class [de/fh_dortmund/hansen/chat/entity/AdditionalEntityInformation]. 
2016-10-19T13:00:01.391+0200|Information: de.fh_dortmund.hansen.chat.entity.AdditionalEntityInformation actually got transformed 
2016-10-19T13:00:01.400+0200|Am feinsten: Begin weaver class transformer processing class [de/fh_dortmund/hansen/chat/entity/UserStatisticEntity]. 
2016-10-19T13:00:01.401+0200|Am feinsten: Weaved change tracking (ChangeTracker) [de/fh_dortmund/hansen/chat/entity/UserStatisticEntity]. 
2016-10-19T13:00:01.401+0200|Am feinsten: Weaved fetch groups (FetchGroupTracker) [de/fh_dortmund/hansen/chat/entity/UserStatisticEntity]. 
2016-10-19T13:00:01.401+0200|Am feinsten: End weaver class transformer processing class [de/fh_dortmund/hansen/chat/entity/UserStatisticEntity]. 
2016-10-19T13:00:01.401+0200|Information: de.fh_dortmund.hansen.chat.entity.UserStatisticEntity actually got transformed 
2016-10-19T13:00:01.402+0200|Am feinsten: Begin weaver class transformer processing class [de/fh_dortmund/hansen/chat/entity/StatisticEntity]. 
2016-10-19T13:00:01.403+0200|Am feinsten: Weaved change tracking (ChangeTracker) [de/fh_dortmund/hansen/chat/entity/StatisticEntity]. 
2016-10-19T13:00:01.404+0200|Am feinsten: Weaved fetch groups (FetchGroupTracker) [de/fh_dortmund/hansen/chat/entity/StatisticEntity]. 
2016-10-19T13:00:01.404+0200|Am feinsten: End weaver class transformer processing class [de/fh_dortmund/hansen/chat/entity/StatisticEntity]. 
2016-10-19T13:00:01.405+0200|Information: de.fh_dortmund.hansen.chat.entity.StatisticEntity actually got transformed 
2016-10-19T13:00:01.420+0200|Am feinsten: Begin weaver class transformer processing class [de/fh_dortmund/hansen/chat/entity/CommonStatisticEntity]. 
2016-10-19T13:00:01.422+0200|Am feinsten: Weaved change tracking (ChangeTracker) [de/fh_dortmund/hansen/chat/entity/CommonStatisticEntity]. 
2016-10-19T13:00:01.422+0200|Am feinsten: Weaved fetch groups (FetchGroupTracker) [de/fh_dortmund/hansen/chat/entity/CommonStatisticEntity]. 
2016-10-19T13:00:01.423+0200|Am feinsten: End weaver class transformer processing class [de/fh_dortmund/hansen/chat/entity/CommonStatisticEntity]. 
2016-10-19T13:00:01.423+0200|Information: de.fh_dortmund.hansen.chat.entity.CommonStatisticEntity actually got transformed 
2016-10-19T13:00:01.449+0200|Feiner: initializing session manager 
2016-10-19T13:00:01.451+0200|Am feinsten: property=eclipselink.target-server; value=SunAS9; translated value=org.eclipse.persistence.platform.server.sunas.SunAS9ServerPlatform 
2016-10-19T13:00:01.451+0200|Am feinsten: property=eclipselink.logging.level; value=FINEST; translated value=FINEST 
2016-10-19T13:00:01.452+0200|Am feinsten: property=eclipselink.logging.level; value=FINEST; translated value=FINEST 
2016-10-19T13:00:01.452+0200|Am feinsten: property=eclipselink.target-database; value=MySQL; translated value=org.eclipse.persistence.platform.database.MySQLPlatform 
2016-10-19T13:00:01.465+0200|Information: EclipseLink, version: Eclipse Persistence Services - 2.6.1.v20150605-31e8258 
2016-10-19T13:00:01.470+0200|Konfiguration: connecting(DatabaseLogin(
    platform=>MySQLPlatform 
    user name=> "" 
    connector=>JNDIConnector datasource name=>null 
)) 
2016-10-19T13:00:01.922+0200|Konfiguration: Connected: jdbc:mysql://localhost:3306/chat 
    User: [email protected] 
    Database: MySQL Version: 5.7.16-log 
    Driver: MySQL Connector Java Version: mysql-connector-java-5.1.40 (Revision: 402933ef52cad9aa82624e80acbea46e3a701ce6) 
2016-10-19T13:00:01.922+0200|Am feinsten: Connection acquired from connection pool [read]. 
2016-10-19T13:00:01.922+0200|Am feinsten: Connection released to connection pool [read]. 
2016-10-19T13:00:01.922+0200|Konfiguration: connecting(DatabaseLogin(
    platform=>MySQLPlatform 
    user name=> "" 
    connector=>JNDIConnector datasource name=>null 
)) 
2016-10-19T13:00:01.923+0200|Konfiguration: Connected: jdbc:mysql://localhost:3306/chat 
    User: [email protected] 
    Database: MySQL Version: 5.7.16-log 
    Driver: MySQL Connector Java Version: mysql-connector-java-5.1.40 (Revision: 402933ef52cad9aa82624e80acbea46e3a701ce6) 
2016-10-19T13:00:01.929+0200|Am feinsten: sequencing connected, state is NoPreallocation_State 
2016-10-19T13:00:01.930+0200|Am feinsten: sequence seqGenStatId: preallocation size 50 
2016-10-19T13:00:01.930+0200|Am feinsten: sequence seqGenUserId: preallocation size 50 
2016-10-19T13:00:02.000+0200|Information: /file:/D:/glassfish4/glassfish/domains/domain1/eclipseApps/Chat-ear/Chat-ejb_jar/_ChatDB login successful 
2016-10-19T13:00:02.000+0200|Feiner: JMX MBeanServer instance found: [[email protected]], # of beans: [24], domain: [DefaultDomain] at index: [0]. 
2016-10-19T13:00:02.002+0200|Am feinsten: Registered MBean: org.eclipse.persistence.services.mbean.MBeanDevelopmentServices[TopLink:Name=Development-/file_/D_/glassfish4/glassfish/domains/domain1/eclipseApps/Chat-ear/Chat-ejb_jar/_ChatDB,Type=Configuration] on server [email protected] 
2016-10-19T13:00:02.003+0200|Am feinsten: Registered MBean: org.eclipse.persistence.services.glassfish.MBeanGlassfishRuntimeServices[TopLink:Name=Session(/file_/D_/glassfish4/glassfish/domains/domain1/eclipseApps/Chat-ear/Chat-ejb_jar/_ChatDB)] on server [email protected] 
2016-10-19T13:00:02.003+0200|Am feinsten: EclipseLink JMX Runtime Services is referencing the [Platform ConversionManager] ClassLoader at: [EarClassLoader : 
urlSet = [URLEntry : file:/D:/glassfish4/glassfish/domains/domain1/eclipseApps/Chat-ear/Chat-ejb_jar/, URLEntry : file:/D:/glassfish4/glassfish/domains/domain1/generated/ejb/Chat-ear/Chat-ejb_jar, URLEntry : file:/D:/glassfish4/glassfish/domains/domain1/eclipseApps/Chat-ear/Chat-common.jar/] 
doneCalled = false 
Parent -> [email protected] 
] 
2016-10-19T13:00:02.003+0200|Am feinsten: The applicationName for the MBean attached to session [/file:/D:/glassfish4/glassfish/domains/domain1/eclipseApps/Chat-ear/Chat-ejb_jar/_ChatDB] is [D:/glassfish4/glassfish/domains/domain1/eclipseApps/Chat-ear/Chat-ejb_jar/_URLEntry _file:/D:/glassfish4/glassfish/domains/domain1/generated/ejb/Chat-ear/Chat-ejb_jar_URLEntry _file:/D:/glassfish4/glassfish/domains/domain1/eclipseApps/Chat-ear/Chat-common.jar/] 
2016-10-19T13:00:02.003+0200|Am feinsten: The moduleName for the MBean attached to session [/file:/D:/glassfish4/glassfish/domains/domain1/eclipseApps/Chat-ear/Chat-ejb_jar/_ChatDB] is [_ChatDB] 
2016-10-19T13:00:02.015+0200|Am feinsten: The table (COMMONSTATISTICENTITY) is created. 
2016-10-19T13:00:02.016+0200|Am feinsten: The table (USERENTITY) is created. 
2016-10-19T13:00:02.016+0200|Am feinsten: The table (USERSTATISTICENTITY) is created. 
2016-10-19T13:00:02.018+0200|Feiner: Canonical Metamodel class [de.fh_dortmund.hansen.chat.entity.StatisticEntity_] not found during initialization. 
2016-10-19T13:00:02.019+0200|Feiner: Canonical Metamodel class [de.fh_dortmund.hansen.chat.entity.CommonStatisticEntity_] not found during initialization. 
2016-10-19T13:00:02.020+0200|Feiner: Canonical Metamodel class [de.fh_dortmund.hansen.chat.entity.UserEntity_] not found during initialization. 
2016-10-19T13:00:02.021+0200|Feiner: Canonical Metamodel class [de.fh_dortmund.hansen.chat.entity.UserStatisticEntity_] not found during initialization. 
2016-10-19T13:00:02.022+0200|Feiner: Canonical Metamodel class [de.fh_dortmund.hansen.chat.entity.AdditionalEntityInformation_] not found during initialization. 
2016-10-19T13:00:02.022+0200|Am feinsten: End deploying Persistence Unit ChatDB; session /file:/D:/glassfish4/glassfish/domains/domain1/eclipseApps/Chat-ear/Chat-ejb_jar/_ChatDB; state Deployed; factoryCount 1 
2016-10-19T13:00:09.314+0200|Fein: SELECT COUNT(USERID) FROM USERENTITY WHERE (USERNAME = ?) 
    bind => [1 parameter bound] 
2016-10-19T13:00:09.333+0200|Am feinsten: Connection released to connection pool [read]. 
2016-10-19T13:00:09.335+0200|Am feinsten: persist() operation called on: [email protected]. 
2016-10-19T13:00:09.397+0200|Feiner: begin unit of work flush 
2016-10-19T13:00:09.397+0200|Feiner: TX beginTransaction, status=STATUS_ACTIVE 
2016-10-19T13:00:09.398+0200|Am feinsten: Execute query InsertObjectQuery([email protected]) 
2016-10-19T13:00:09.398+0200|Am feinsten: Connection acquired from connection pool [default]. 
2016-10-19T13:00:09.398+0200|Am feinsten: reconnecting to external connection pool 
2016-10-19T13:00:09.399+0200|Fein: INSERT INTO COMMONSTATISTICENTITY (CREATEDAT, ENDDATE, LOGINS, LOGOUTS, MESSAGES, STARTINGDATE, UPDATEDAT) VALUES (?, ?, ?, ?, ?, ?, ?) 
    bind => [7 parameters bound] 
2016-10-19T13:00:09.405+0200|Am feinsten: Execute query ValueReadQuery(name="seqGenStatId" sql="SELECT LAST_INSERT_ID()") 
2016-10-19T13:00:09.405+0200|Fein: SELECT LAST_INSERT_ID() 
2016-10-19T13:00:09.406+0200|Am feinsten: assign sequence to the object (1 -> [email protected]) 
2016-10-19T13:00:09.407+0200|Feiner: end unit of work flush 
2016-10-19T13:00:09.408+0200|Feiner: resume unit of work 
2016-10-19T13:00:09.408+0200|Am feinsten: Execute query ReportQuery(name="getNumUsersWithName" referenceClass=UserEntity sql="SELECT COUNT(USERID) FROM USERENTITY WHERE (USERNAME = ?)") 
2016-10-19T13:00:09.409+0200|Fein: SELECT COUNT(USERID) FROM USERENTITY WHERE (USERNAME = ?) 
    bind => [1 parameter bound] 
2016-10-19T13:00:09.412+0200|Am feinsten: persist() operation called on: [email protected] 
2016-10-19T13:00:09.421+0200|Feiner: TX beforeCompletion callback, status=STATUS_ACTIVE 
2016-10-19T13:00:09.421+0200|Feiner: begin unit of work commit 
2016-10-19T13:00:09.422+0200|Am feinsten: Execute query InsertObjectQuery([email protected]) 
2016-10-19T13:00:09.423+0200|Fein: INSERT INTO USERENTITY (CREATEDAT, LOGGEDIN, PASSWORDHASH, STATS, UPDATEDAT, USERNAME) VALUES (?, ?, ?, ?, ?, ?) 
    bind => [6 parameters bound] 
2016-10-19T13:00:09.425+0200|Am feinsten: Execute query ValueReadQuery(name="seqGenUserId" sql="SELECT LAST_INSERT_ID()") 
2016-10-19T13:00:09.425+0200|Fein: SELECT LAST_INSERT_ID() 
2016-10-19T13:00:09.426+0200|Am feinsten: assign sequence to the object (1 -> [email protected]) 
2016-10-19T13:00:09.431+0200|Am feinsten: Connection released to connection pool [default]. 

EDIT2: UserStatisticEntity сериализует по наследству, если я удалю эту serializablility, мои EJB перерывы развертывания, с этой ошибкой:

Exception Description: The type [class de.fh_dortmund.hansen.chat.entity.UserStatisticEntity] for the attribute [stats] on the entity class [class de.fh_dortmund.hansen.chat.entity.UserEntity] is not a valid type for a serialized mapping. The attribute type must implement the Serializable interface. 
+0

почему бы не опубликовать схему создатель поставщика JPA, код упорству, журнал? –

+0

Добавлена ​​созданная схема (как сказано в важном бите), я предполагаю, что ошибка имеет какое-то отношение, почему STATS создается как longblob, а не как внешний ключ/bigint. Что такое код персистентности? Потребуется немного дольше, чтобы найти правильный журнал. – Lumentus

+0

Вы положили '@ Entity' на свою другую сущность ?! «код сохранения» - это вызовы API JPA, которые вы использовали для создания и PERSIST для своих объектов. –

ответ

1

Решения действительно просто как я думал. По какой-то причине Eclipselink действительно обеспокоен тем фактом, что для одного UserStatisticEntity является сериализуемым и что у меня есть все эти аннотации в поле статистики. После того, как делает его несериализуемая и последующим удалением @Basic и @column аннотациями следующий код работает:

@OneToOne(cascade={CascadeType.PERSIST, CascadeType.REMOVE}) 
@JoinColumn(nullable=false,unique=true) 
private UserStatisticEntity stats; 
+0

любой связанный объект может быть сериализуемым, поэтому, если Eclipselink действительно имеет проблемы с этим, то поднимите ошибку у вашего провайдера.'@ Basic' в поле отношения является неправильным, но не должен заставлять вашего поставщика JPA делать странные вещи - он должен просто указывать ошибку (возможно, зарегистрирован) и продолжить –

+0

После того, как я сделал UserStatisticEntity несериализуемым, я также удалил как' @ JoinColumn' и '@ Basic'. Затем Eclipselink начал жаловаться, что я должен использовать '@ JoinColumn' вместо' @ Column', который каким-то образом получил Eclipselink, чтобы понять, что он должен использовать внешний ключ вместо blob. – Lumentus

Смежные вопросы