List listDataClient;
My class DataCLient:
Client client; List<String> phoneNumber;
i have a second list
List<DataPhoneNumber> listPhoneNumber;
Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
My class DataPhoneNumber:
String phoneNumber; List<Client> client;
In my code i put data in my first list but now i want to reverse my list in the second. In the first list i have a Client wiht x NumberPhone now i want to have NumberPhone for x Client
I'm not claiming it is the case but this might be a bug in the underlying generator used by Hibernate. See for example this post on Hibernate's forums that describes a weird behavior, the issues mentioned in the comments of the New (3.2.3) Hibernate identifier generators or existing issues in Jira.
My suggestion would be to identify the generator used in your case and to search for an existing issues or to open a new one.
听起来您正在尝试建立多对多关系的模型。
一种方法是创建一个类来明确表示这种关系PhoneNumberAssociation:例如
PhoneNumberAssociation
public class PhoneNumberAssociation { private final Set<Client> clients; private final Set<String> phoneNumbers; public void addClient(Client client) { this.clients.add(client); } public void addPhoneNumber(String phoneNumber) { this.phoneNumbers.add(phoneNumber); } }
当他们在关系中没有明显的父母或孩子角色时,我倾向于使用这种方法。它也比在多个对象中嵌入列表并且必须根据电话号码是否被添加到客户端/从客户端中删除(或者相反,如果客户端正在添加到电话号码中/从电话号码中删除)链接调用来添加/删除更简单)。