- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
当我尝试保存数据时,显示此错误:
com.LTR.entity.Silicon.platform -> com.LTR.entity.Platform,
它说我需要保存 transient 。
我一直在尝试放置cascadeType.ALL,但这不起作用。
@Entity
@Table(name="silicon",uniqueConstraints={@UniqueConstraint(columnNames = {"silicon_visual_id"})})
@EnableTransactionManagement
@DynamicUpdate
public class Silicon implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy=GenerationType.IDENTITY)
@Column(name="id", unique = true, nullable = false)
private Long id;
@Column(name="mir", unique = false, nullable = true)
private Long mir;
@Column(name = "silicon_name", nullable = false, length= 45)
private String siliconName;
@Column(name = "type_silicon", nullable = false, length= 45)
private String typeSilicon;
@Column(name = "qdf", nullable = true, length= 45)
private String qdf;
@Column(name = "silicon_visual_id", nullable = false, length= 45)
private String siliconVisualId;
@Column(name = "cpu_id", nullable = true, length= 45)
private String cpuId;
@Column(name = "stepping", nullable = true, length= 45)
private String stepping;
@Column(name = "socket", nullable = true, length= 45)
private String socket;
@Column(name = "status_silicon", nullable = false,length= 45)
private String statusSilicon;
@JsonIgnore
@ManyToOne(fetch=FetchType.EAGER)
@JoinColumn(name="user_owner", nullable = false)
private User userOwner;
@DateTimeFormat(pattern = "yyyy-MM-dd")
@Column(name = "date_admission", nullable = false)
private Date dateAdmission;
@JsonIgnore
@ManyToOne(fetch=FetchType.EAGER)
@JoinColumn(name="user_request", nullable = true)
private User userRequest;
@JsonIgnore
@ManyToOne(fetch=FetchType.EAGER)
@JoinColumn(name="user_last_returned", nullable = true)
private User userLastReturned;
@DateTimeFormat(pattern = "yyyy-MM-dd")
@Column(name = "date_delivered", nullable = true)
private Date dateDelivered;
@JsonIgnore
@ManyToOne(fetch=FetchType.EAGER)
@JoinColumn(name="platform_current", nullable = true)
private Platform platform;
@JsonIgnore
@ManyToOne(fetch=FetchType.EAGER)
@JoinColumn(name="platform_own", nullable = true,updatable= false)
private Platform platformOwn;
/*GETTERS AND SETTERS*/
@Entity
@Table(name="platform")
public class Platform implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy=GenerationType.IDENTITY)
@Column(name="platform_id", unique = true, nullable = false)
private Long platformId;
@JsonIgnore
@ManyToOne(fetch=FetchType.EAGER)
@JoinColumn(name="locationId", nullable = false)
private Location location;
@Enumerated(EnumType.STRING)
@JoinColumn(name="businessUnit", nullable = true)
private BusinessUnit businessUnit;
@Column(name = "name", nullable = false, length= 45,unique = true)
private String name;
@Column(name = "project", nullable = false, length= 45)
private String project;
@Column(name = "serialPlatform", nullable = false, length= 45, unique
= true)
private String serialPlatform;
@Column(name = "model", nullable = false, length= 45)
private String model;
@Column(name = "chasisSerial", nullable = false, length= 45)
private String chasisSerial;
@Column(name = "chasisModel", nullable = false, length= 45)
private String chasisModel;
@Column(name = "ismpKitName", nullable = false, length= 45)
private String ismpKitName;
@Column(name = "ismpSerialNumber", nullable = false, length= 45)
private String ismpSerialNumber;
@Column(name = "assignedTo", nullable = false, length= 45)
private String assignedTo;
@Column(name = "OwnedBy", nullable = false, length= 45)
private String OwnedBy;
@Column(name = "ismNumber", nullable = false, length= 45)
private int ismNumber;
@DateTimeFormat(pattern = "yyyy-MM-dd")
@Column(name = "receivedDate", nullable = false)
private Date receivedDate;
@Column(name = "asset", nullable = false, length= 45)
private int asset;
@Column(name = "startStatus", nullable = false, length= 45)
private boolean startStatus;
@Column(name = "finalStatus", nullable = false, length= 45)
private boolean finalStatus;
@Column(name = "cloudReady", nullable = false, length= 45)
private boolean cloudReady;
@OneToMany(mappedBy="platform")
private List annotations;
@OneToMany(fetch = FetchType.LAZY,cascade = CascadeType.ALL, mappedBy
= "platform")
private Set userRole = new HashSet();
@OneToOne(fetch = FetchType.LAZY, mappedBy = "platform")
private Host Host;
/*GETTERS AND SETTERS*/
org.springframework.dao.InvalidDataAccessApiUsageException: org.hibernate.TransientPropertyValueException: object references an unsaved transient instance - save the transient instance before flushing : com.LTR.entity.Silicon.platform -> com.LTR.entity.Platform; nested exception is java.lang.IllegalStateException: org.hibernate.TransientPropertyValueException: object references an unsaved transient instance - save the transient instance before flushing : com.LTR.entity.Silicon.platform -> com.LTR.entity.Platform
2019-09-09 08:32:43.161 ERROR 21968 --- [nio-8081-exec-9] o.h.i.ExceptionMapperStandardImpl : HHH000346: Error during managed flush [org.hibernate.TransientPropertyValueException: object references an unsaved transient instance - save the transient instance before flushing : com.LTR.entity.Silicon.platform -> com.LTR.entity.Platform]
2019-09-09 08:32:43.172 INFO 21968 --- [nio-8081-exec-9] com.LTR.controller.SiliconController : org.springframework.dao.InvalidDataAccessApiUsageException: org.hibernate.TransientPropertyValueException: object references an unsaved transient instance - save the transient instance before flushing : com.LTR.entity.Silicon.platform -> com.LTR.entity.Platform; nested exception is java.lang.IllegalStateException: org.hibernate.TransientPropertyValueException: object references an unsaved transient instance - save the transient instance before flushing : com.LTR.entity.Silicon.platform -> com.LTR.entity.Platform
2019-09-09 09:25:45.500 WARN 8000 --- [nio-8081-exec-1] o.h.engine.jdbc.spi.SqlExceptionHelper : SQL Error: 1048, SQLState: 23000
2019-09-09 09:25:45.500 ERROR 8000 --- [nio-8081-exec-1] o.h.engine.jdbc.spi.SqlExceptionHelper : Column 'owned_by' cannot be null
2019-09-09 09:25:45.506 ERROR 8000 --- [nio-8081-exec-1] o.h.i.ExceptionMapperStandardImpl : HHH000346: Error during managed flush [org.hibernate.exception.ConstraintViolationException: could not execute statement]
2019-09-09 09:25:45.517 INFO 8000 --- [nio-8081-exec-1] com.LTR.controller.SiliconController : org.springframework.dao.DataIntegrityViolationException: could not execute statement; SQL [n/a]; constraint [null]; nested exception is org.hibernate.exception.ConstraintViolationException: could not execute statement
我不知道为什么当我尝试更新或插入此错误时崩溃了,而且只有当我尝试更新时平台对象为空时才会发生这种情况
当我设置cascadeType.ALL时,平台实体的ownedBy为空,但数据库中不为空
1 Câu trả lời
您需要在保存芯片之前保存平台,因此 Persist 是您在此处需要的 CascadeType。
@JsonIgnore
@ManyToOne(fetch=FetchType.EAGER, cascade = CascadeType.PERSIST)
@JoinColumn(name="platform_current", nullable = true)
private Platform platform;
关于java - 对象引用未保存的 transient 实例 - 在刷新 hibernate JPA 之前保存 transient 实例,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57856022/
我知道这个问题已经被问过很多次了,但我找不到适合我的答案。 我在 Spring Roo 应用程序中有两个实体,它们处于多对多关系、发布和组件中。 首先,我通过以下方式获取现有版本的实例 selecte
我正在尝试将用户详细信息存储到下表中:user、role、user_role。尝试保存详细信息时,它会引发以下错误。 Error during managed flush [org.hibernate
我有两个 hibernate 实体 Coupon 和 CouponHistory,在 CouponHistory 和 Coupon 之间具有单向关系。 @Entity @Table(name = "v
我在外键 dimension_id 之一的表中有表 product。所以在服务层编写我的测试用例时它显示了错误。 这是我的测试用例 @Transactional(propagation = Propa
在 ARM 架构手册中提到缓存可以是 transient 的和非 transient 的,并且它是由实现定义的。我无法理解关于缓存的 transient 内存的概念和使用。我正在尝试编写启用 MMU
我有 2 个域模型和一个 Spring REST Controller ,如下所示: @Entity public class Customer{ @Id private Long id; @OneT
Tôi biết câu hỏi này đã có nhiều câu hỏi trên Stackoverflow, nhưng ngay cả với nhiều câu trả lời, những câu trả lời đó cũng không giúp ích cho tôi nhiều và tôi không tìm ra câu trả lời. Trong WebAPP của tôi, nó hoạt động tốt, nhưng khi tôi chuyển đổi nó thành API thì nó không hoạt động (nhãn chủ đề
我有以下域名 class User { Boolean accountLocked String password Boolean passwordExpired Bo
我写了一个 elisp 宏,在 transient-mark-mode 中保留区域: (defmacro keep-region (command) "Wrap command in code t
这是我的员工类(class): @Entity public class Employee { @Id @GeneratedValue private int id; private String f
我正在通读 Windows Phone 7.5 Unleashed,有很多代码看起来像这样(在页面的代码隐藏中): bool loaded; protected override void OnNav
Tôi có một lớp thực thể nhân viên tự liên kết với các cột id, name và ref liên quan đến chính nó. Tôi muốn tạo một phiên bản mới của nó và lưu nó vào cơ sở dữ liệu. Đầu tiên tôi tạo một thể hiện của lớp Employee và đặt tên là manager. Sau đó
Tôi có một biểu mẫu để thêm căn hộ mới, trong biểu mẫu đó tôi có một menu thả xuống nơi người dùng có thể chọn người chịu trách nhiệm. Có vẻ như khi bạn chọn từ danh sách thả xuống và cố gắng lưu căn hộ, ứng dụng của tôi nghĩ rằng người đó đã bị thay đổi. Nó cho tôi lỗi sau đây chỉ ra rằng tôi nên lưu trước
我正在尝试保存一个复杂的对象,该对象内部有许多引用元素,而且它在大多数情况下都能完美运行。 但是在某些情况下,我们会遇到以下异常, object references an unsaved trans
Tôi đã tìm thấy một số câu trả lời khả thi cho câu hỏi của mình, nhưng câu trả lời ở đây là về việc nâng cấp từ Hibernate 3.4.0GA lên Hibernate 4.1.8. Vì vậy, điều này từng hoạt động trong các phiên bản trước, tôi đã tìm kiếm xung quanh để biết lý do tại sao nó bị hỏng trong phiên bản mới này
Có vẻ như câu hỏi này được hỏi đi hỏi lại nhiều lần và tôi vẫn không thể tìm ra câu trả lời giải quyết được vấn đề của mình. Tôi có mô hình miền như bên dưới. Mỗi "Người dùng bảo mật" mới được tạo hoặc cập nhật đều yêu cầu tôi phải đảm bảo rằng người dùng đó có hồ sơ, nếu chưa có, tôi sẽ tạo một hồ sơ mới và chỉ định cho người dùng đó. Yêu cầu về tập tin cấu hình
Tôi đang gặp khó khăn trong việc tìm ra lý do tại sao JPA không phân tầng mối quan hệ @ManyToMany của tôi. Tất cả các câu trả lời tôi tìm thấy đều liên quan đến các câu lệnh cascade bị thiếu. Nhưng tôi có chúng và vẫn nhận được: Do: org.hibernate.Transi
例如,当我使用 transient 通过更改 translate(x, y) 的值来实现 2s 持续时间的动画时。如何获取0.5s时刻translate(x, y)的当前值? 最佳答案 我认为你做不到
我在尝试保存属于多对多关联的对象时收到 TransientObjectException。我有点理解为什么会这样,但想了解如何正确完成我正在尝试做的事情。 简而言之,我正在尝试做的事情: 我的应用程序
transient final int 和 transient final Integer 有什么不同。 使用 int: transient final int a = 10; 序列化前: a = 1
Tôi là một lập trình viên xuất sắc, rất giỏi!