- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我在 table 上做了一个“简单的”,它给出了这个错误。搜索网络没有帮助。
我认为使用序列作为我的主键源与我有关。
你能帮忙吗?谢谢
我正在尝试运行的代码(我已经突出显示了引发错误的部分)
EventInstance eventInstance = (EventInstance) sessionFactory.getCurrentSession().get(EventInstance.class, userEventRegistration.getEventInstance().getInstanceId());
Student student = (Student) sessionFactory.getCurrentSession().get(Student.class, userEventRegistration.getStudent().getStudentId());
EventRegistration eventRegistration = new EventRegistration();
if (student == null) {
student = new Student();
student.setStudentId(userEventRegistration.getStudent().getStudentId());
}
student.setFamilyName(userEventRegistration.getStudent().getFamilyName());
student.setGivenName(userEventRegistration.getStudent().getGivenName());
student.setGender(userEventRegistration.getStudent().getGender());
student.setEmail(userEventRegistration.getStudent().getEmail());
student.setHomeCountry(userEventRegistration.getStudent().getHomeCountry());
student.setCourse(userEventRegistration.getStudent().getCourse());
student.setAccomodationName(userEventRegistration.getStudent().getAccomodationName());
student.setAddress(userEventRegistration.getStudent().getAddress());
student.setAddressCity(userEventRegistration.getStudent().getAddressCity());
student.setContactPhone(userEventRegistration.getStudent().getContactPhone());
student.setContactDetailsStatus(userEventRegistration.getStudent().getContactDetailsStatus());
student.setContactDetailsDate(userEventRegistration.getStudent().getContactDetailsDate());
student.setScholarships(userEventRegistration.getStudent().getScholarships());
student.setDietaryRestrictions(userEventRegistration.getStudent().getDietaryRestrictions());
student.setStudentComments(userEventRegistration.getStudent().getStudentComments());
student.setInternalComments(userEventRegistration.getStudent().getInternalComments());
eventRegistration.setEventInstance(eventInstance);
eventRegistration.setStudent(student);
eventRegistration.setAttended(userEventRegistration.getAttended());
eventRegistration.setSubmitDateTime(new Date());
eventRegistration.setAdditionalInfo(userEventRegistration.getAdditionalInfo());
eventRegistration.setNumberAttending(userEventRegistration.getNumberAttending());
eventRegistration.setArchiveDate(userEventRegistration.getArchiveDate());
**sessionFactory.getCurrentSession().save(eventRegistration);**
sessionFactory.getCurrentSession().getTransaction().commit();
hibernate 映射
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class name="com.myapps.issu.models.database.Event" table="events">
<id name="eventId" column="event_id" type="integer" />
<property name="eventName" column="event_name" type="string" />
<property name="eventType" column="event_type" type="string" />
<property name="descriptionBrief" column="description_brief" type="string" />
<property name="descriptionFull" column="description_full" type="string" />
<property name="location" column="location" type="string" />
<property name="cost" column="cost" type="string" />
<property name="compulsory" column="compulsory" type="string" />
<property name="comments" column="comments" type="string" />
<property name="maxAttendance" column="max_attendance" type="integer" />
<property name="askDietaryRestrictions" column="ask_dietary_restrictions" type="integer" />
<property name="limitPerStudent" column="limit_per_student" type="string" />
<list name="eventInstance" table="event_instances" inverse="false" cascade="all">
<key column="event_id" />
<list-index column="idx" />
<one-to-many class="com.myapps.issu.models.database.EventInstance" />
</list>
</class>
<class name="com.myapps.issu.models.database.Student" table="students">
<id name="studentId" column="student_id" type="string" />
<property name="familyName" column="family_name" type="string" />
<property name="givenName" column="given_name" type="string" />
<property name="fan" column="fan" type="string" />
<property name="gender" column="gender" type="string" />
<property name="email" column="email" type="string" />
<property name="homeCountry" column="home_country" type="string" />
<property name="course" column="course" type="string" />
<property name="accomodationName" column="accomodation_name" type="string" />
<property name="address" column="address" type="string" />
<property name="addressCity" column="address_city" type="string" />
<property name="contactPhone" column="contact_phone" type="string" />
<property name="contactDetailsStatus" column="contact_details_status" type="string" />
<property name="contactDetailsDate" column="contact_details_date" type="date" />
<property name="scholarships" column="scholarships" type="string" />
<property name="dietaryRestrictions" column="dietary_restrictions" type="string" />
<property name="studentComments" column="student_comments" type="string" />
<property name="internalComments" column="internal_comments" type="string" />
<list name="eventRegistration" table="event_registrations" inverse="false" cascade="all">
<key column="registration_id" />
<list-index column="idx" />
<one-to-many class="com.myapps.issu.models.database.EventRegistration" />
</list>
</class>
<class name="com.myapps.issu.models.database.EventInstance" table="event_instances">
<id name="instanceId" column="instance_id" type="integer" />
<many-to-one name="event" class="com.myapps.issu.models.database.Event" column="event_id" fetch="select" not-null="true" />
<property name="startDateTime" column="start_date_time" type="date" />
<property name="finishDateTime" column="finish_date_time" type="date" />
<property name="locationIfDifferent" column="location_if_different" type="string" />
<property name="registerCutoffDate" column="register_cutoff_date" type="date" />
<property name="maxAttendance" column="max_attendance" type="integer" />
<property name="askDietaryRestrictions" column="ask_dietary_restrictions" type="string" />
<property name="limitPerStudent" column="limit_per_student" type="integer" />
<property name="archiveDate" column="archive_date" type="date" />
<property name="rollcallProcessed" column="rollcall_processed" type="string" />
<property name="linkedInstance" column="linked_instance" type="integer" />
<list name="eventRegistration" table="event_registrations" inverse="false" cascade="all">
<key column="instance_id" />
<list-index column="idx" />
<one-to-many class="com.myapps.issu.models.database.EventInstance" />
</list>
</class>
<class name="com.myapps.issu.models.database.EventRegistration" table="event_registrations">
<id name="registrationId" column="registration_id" type="integer">
<generator class="sequence-identity" >
<param name="sequence">REGISTRATIONS_SEQ</param>
</generator>
</id>
<many-to-one name="eventInstance" class="com.myapps.issu.models.database.EventInstance" column="instance_id" not-null="true" />
<many-to-one name="student" class="com.myapps.issu.models.database.Student" column="student_id" not-null="true" />
<property name="attended" column="attended" type="string" />
<property name="submitDateTime" column="submit_date_time" type="date" />
<property name="additionalInfo" column="additional_info" type="string" />
<property name="numberAttending" column="number_attending" type="integer" />
<property name="archiveDate" column="archive_date" type="date" />
</class>
<class name="com.myapps.issu.models.database.Lov" table="Lov">
<id name="lovId" column="lov_id" type="integer" />
<property name="kind" column="kind" type="string" />
<property name="code" column="code" type="string" />
<property name="description" column="description" type="string" />
</class>
</hibernate-mapping>
错误信息
org.hibernate.AssertionFailure: getGeneratedKeys() support is not enabled
org.hibernate.engine.jdbc.internal.StatementPreparerImpl.checkAutoGeneratedKeysSupportEnabled(StatementPreparerImpl.java:93)
org.hibernate.engine.jdbc.internal.StatementPreparerImpl.prepareStatement(StatementPreparerImpl.java:112)
org.hibernate.id.SequenceIdentityGenerator$Delegate.prepare(SequenceIdentityGenerator.java:106)
org.hibernate.id.insert.AbstractReturningDelegate.performInsert(AbstractReturningDelegate.java:55)
org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2936)
org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:3447)
org.hibernate.action.internal.EntityIdentityInsertAction.execute(EntityIdentityInsertAction.java:81)
org.hibernate.engine.spi.ActionQueue.execute(ActionQueue.java:362)
org.hibernate.engine.spi.ActionQueue.addResolvedEntityInsertAction(ActionQueue.java:203)
org.hibernate.engine.spi.ActionQueue.addInsertAction(ActionQueue.java:183)
org.hibernate.engine.spi.ActionQueue.addAction(ActionQueue.java:167)
org.hibernate.event.internal.AbstractSaveEventListener.addInsertAction(AbstractSaveEventListener.java:320)
org.hibernate.event.internal.AbstractSaveEventListener.performSaveOrReplicate(AbstractSaveEventListener.java:287)
org.hibernate.event.internal.AbstractSaveEventListener.performSave(AbstractSaveEventListener.java:193)
org.hibernate.event.internal.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:126)
org.hibernate.event.internal.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:204)
org.hibernate.event.internal.DefaultSaveEventListener.saveWithGeneratedOrRequestedId(DefaultSaveEventListener.java:55)
org.hibernate.event.internal.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:189)
org.hibernate.event.internal.DefaultSaveEventListener.performSaveOrUpdate(DefaultSaveEventListener.java:49)
org.hibernate.event.internal.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:90)
org.hibernate.internal.SessionImpl.fireSave(SessionImpl.java:756)
org.hibernate.internal.SessionImpl.save(SessionImpl.java:748)
org.hibernate.internal.SessionImpl.save(SessionImpl.java:744)
au.edu.flinders.issu.dao.IssuDaoImpl.saveEventRegistration(IssuDaoImpl.java:64)
au.edu.flinders.issu.services.IssuServiceImpl.saveEventRegistration(IssuServiceImpl.java:24)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
java.lang.reflect.Method.invoke(Method.java:601)
org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:319)
org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:183)
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)
org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:110)
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)
$Proxy13.saveEventRegistration(Unknown Source)
au.edu.flinders.issu.controllers.IssuController.saveEventRegistration(IssuController.java:41)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
java.lang.reflect.Method.invoke(Method.java:601)
org.springframework.web.method.support.InvocableHandlerMethod.invoke(InvocableHandlerMethod.java:219)
org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:132)
org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:100)
org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:604)
org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:565)
org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:80)
org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:923)
org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:852)
org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:882)
org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:778)
javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
最佳答案
我遇到了同样的问题。终于找到了出路。将此行放入您的 hibernate.cfg.xml 文件中。
<property name="hibernate.jdbc.use_get_generated_keys">true</property>
可以在以下位置找到引用和解释:
关于hibernate - org.hibernate.AssertionFailure : getGeneratedKeys() support is not enabled (using Oracle11g),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14452602/
有时我的线程执行时会遇到这个奇怪的错误。这可能与什么有关? 2011-Jun-25 09:05:22,339 ERROR AssertionFailure:45 - an assertion fail
我通过一个 session 连接到我的数据库。在我的整个程序中,我总是有相同的 session 。我的线程“1”从数据库中捕获主要数据。必须允许用户取消此线程。因此,如果用户经常或快速按下取消按钮(这
我有点困惑,找不到关于这个案例的正确信息。我们从文档中都知道: Use this function to stop the program, without impacting the perform
在我看来,assertionFailure 将在发布版本中被忽略。但是当我在 Release模式下运行下面的代码时,assertionFailure 可以运行和停止程序。为什么? 代码 enum Me
更新:我简化了这个问题的代码,并删除了原始的、更复杂的代码。 请帮助我了解导致我在下面描述的错误的原因。 我定义了一个简单的 4xfloat vector 类型 Vector4f .现在我只定义了索引
我建立了一个非常基本的Grails 3网络应用程序,它使用jdbc连接到PostgreSQL数据库。您可以在下面找到Cluster域类和专用服务的代码。 碰巧用相同的createCluster参数两次
我有个问题。我收到以下异常: ERROR [org.hibernate.AssertionFailure] (http-0.0.0.0-80-10) an assertion failure occu
我尝试根据文档为 iOS 实现 Google 登录 - iOS implentation .但是应用程序在调用时因错误而崩溃 [[GGLContext sharedInstance] configur
我在尝试创建对象时不断收到 org.hibernate.AssertionFailure: null identifier。我的类(class)如下: public class User {
当我尝试在一些删除操作后进行读取时,出现此 hibernate 断言错误。 我找不到关于此“无法执行取消删除”错误的任何信息,except the soure code ,所以我认为,也许我做的事情显
我对 OneToMany/ManyToOne 关系有疑问: 类项目: @OneToMany(fetch = FetchType.EAGER,cascade = CascadeType.ALL, orp
问题:错误 500:内部服务器错误 URI: /listing/save Class: org.hibernate.AssertionFailure Message: getGeneratedKeys
编辑:得到-1,请您解释为什么?我搜索了重复项,但没有找到任何重复项。 发布我刚刚遇到的问题的问题解答: class Pineapple { def pineappleService
我在 table 上做了一个“简单的”,它给出了这个错误。搜索网络没有帮助。 我认为使用序列作为我的主键源与我有关。 你能帮忙吗?谢谢 我正在尝试运行的代码(我已经突出显示了引发错误的部分)
我正在开发一个使用 AngularJs 作为前端、Spring+Hibernate 作为服务层的 Web 应用程序。服务层有一组 AngularJs 使用的 REST API。应用程序的前端没有大问题
我正在通过 Hibernate 将记录从文件批量处理到 MySQL。我正在尝试迭代记录并保存它们,在 ConstraintViolationException 上我正在尝试更新 catch 子句中的记
我正在尝试使用 Spring Boot 和EntityManager 来访问MySQL 数据库。但如果我使用 session.enableFilter 它会导致奇怪的异常。在互联网上尝试了很多搜索,但
我有一个使用 Tomcat、MySQL 和 Hibernate 的 Java EE 网络应用程序。在我的本地安装 (Windows) 中,一切都很完美。将导出的 war 文件放入服务器 (Linux
我遇到了以下错误: com.google.gwt.user.server.rpc.UnexpectedException: Service method 'public abstract void c
我有一个 hibernate 和 JSF2 应用程序进入部署服务器并突然抛出 org.hibernate.AssertionFailure: null id in exception。我将立即提供堆栈
我是一名优秀的程序员,十分优秀!