子对象更新问题 - Hibernate

时间:2015-07-06 15:27:32

标签: java mysql hibernate jdbc

每次更新父对象时都会重新创建子对象并且不会更新子对象, public class Account extends PersonalInformation { @Column(name="username") private String username; @Column(name="password") private String password; @Column(name="activatedDate") private Date activatedDate; @Column(name="expiredDate") private Date expiredDate; @OneToOne(cascade=CascadeType.ALL) @JoinColumn(name="priv_id") private Privilege priv; @OneToOne(cascade=CascadeType.ALL) @JoinColumn(name="access_id") private AccessPoint access; } 级联:全部重新创建且未更新。

父对象:

public class AccessPoint {
    // % by default from everywhere;
    @Id
    @GeneratedValue(strategy=GenerationType.AUTO)
    private long id;

    @Column(name="host")
    private String host;

    @Column(name="port")
    private String port;

    @Column(name="country")
    private String country;

    @Column(name="town")
    private String town;

    @OneToOne(cascade=CascadeType.ALL)
    @JoinColumn(name="account_id")
    private Account account
}

子对象:

server task default-webseald-xxxx trace set pdweb.snoop 9 file path=c:/pdweb.snoop.txt,rollover_size=100000000

server task default-webseald-xxxx trace set pdweb.debug 9 file path=c:/pdweb.debug.txt,rollover_size=100000000

0 个答案:

没有答案