gpt4 book ai didi

java - 是否可以将对象映射到现有表的一部分?

转载 作者:行者123 更新时间:2023-11-29 06:13:16 24 4
gpt4 key购买 nike

是否可以将对象映射到数据库中现有表的一部分?例如:

public class Account {

private Integer id;

private Integer accountNumber;

@Id
public Integer getId() {
return this.id;
}

@Column(nullable=false)
public Integer getAccountNumber() {
return this.accountNumber;
}

}

在数据库中(只是为了这个问题):

 Account

- id
- accountnumber

- lastmodified
- localbranchid

最佳答案

是的,您只能将数据库表中的一部分列映射到 Account 类(您只需映射您感兴趣的列),但是如果您需要将新的 Account 插入数据库并且未映射的列具有非空约束且没有数据库默认值,您将遇到问题。

关于java - 是否可以将对象映射到现有表的一部分?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6008809/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com