one-to-many

NHibernate Many-to-one cascade

别来无恙 提交于 2019-12-18 06:06:11
问题 I have the below two classes: public class Project { public virtual int ProjectId { get; set; } public virtual string ProjectName { get; set; } public virtual LegalEntity LegalEntity { get; set; } } and public class LegalEntity { public virtual int LegalEntId { get; set; } public virtual string Name { get; set; } } with mappings as: <class name="Project" table="Project" dynamic-update="true"> <id name="ProjectId"> <generator class="native"/> </id> <property name="ProjectName" /> <many-to-one

JPA Composite key with ManyToOne getting org.hibernate.PropertyAccessException: could not set a field value by reflection setter of

☆樱花仙子☆ 提交于 2019-12-18 05:45:21
问题 I have a composite key ContractServiceLocationPK made out of three id's ( contractId , locationId , serviceId ) of type long in an embeddable class. The class which uses this composite key, ContractServiceLocation , maps these ids, using @MapsId annotation, to their objects. Here's how it looks like (removed setters/getters and irrelevant properties): Contract @Entity @Table(name = "Contract") public class Contract implements Serializable { public Contract() { } @Id @GeneratedValue private

Fluent nHibernate: one-to-many relationship Issue

…衆ロ難τιáo~ 提交于 2019-12-18 03:49:25
问题 I have a problem with one-to-many relationships. I have the following domain classes: public class Installation : Entity<Installation> { public virtual string Name { get; set; } public virtual IList<Institution> Institutions { get; set; } public Installation() { Institutions = new List<Institution>(); } } public class Institution : Entity { public virtual string Name { get; set; } public virtual string Address { get; set; } public virtual string City { get; set; } public virtual Installation

Hibernate @OneToMany remove child from list when updating parent

被刻印的时光 ゝ 提交于 2019-12-17 21:47:51
问题 I have the following entities: TEAM @Entity @Table public class Team { [..] private Set<UserTeamRole> userTeamRoles; /** * @return the userTeamRoles */ @OneToMany(cascade = { CascadeType.ALL }, mappedBy = "team", fetch = FetchType.LAZY) public Set<UserTeamRole> getUserTeamRoles() { return userTeamRoles; } /** * @param userTeamRoles * the userTeamRoles to set */ public void setUserTeamRoles(Set<UserTeamRole> userTeamRoles) { this.userTeamRoles = userTeamRoles; } } and USER_TEAM_ROLE @Entity

Hibernate inserts duplicates into a @OneToMany collection

北城余情 提交于 2019-12-17 09:49:37
问题 I have a question concerning Hibernate 3.6.7 and JPA 2.0. Consider following entities (some getters and setters are omitted for brevity): @Entity public class Parent { @Id @GeneratedValue private int id; @OneToMany(mappedBy="parent") private List<Child> children = new LinkedList<Child>(); @Override public boolean equals(Object obj) { return id == ((Parent)obj).id; } @Override public int hashCode() { return id; } } @Entity public class Child { @Id @GeneratedValue private int id; @ManyToOne

AttributeError: 'int' object has no attribute '_sa_instance_state'

守給你的承諾、 提交于 2019-12-17 09:33:10
问题 I'm working on forum template using Flask. When I attempt creating a new thread in the browser using forms, SQLAlchemy throws an AttributeError. The problem showed up when I tried implementing a one-to-many relationship with Forum-to-Thread and a one-to-many relationship with Thread-to-User. models.py class User(db.Model): id = db.Column(db.Integer, primary_key=True) username = db.Column(db.String(32), index=True, unique=True) password = db.Column(db.String(32), index=True) email = db.Column

AttributeError: 'int' object has no attribute '_sa_instance_state'

最后都变了- 提交于 2019-12-17 09:32:16
问题 I'm working on forum template using Flask. When I attempt creating a new thread in the browser using forms, SQLAlchemy throws an AttributeError. The problem showed up when I tried implementing a one-to-many relationship with Forum-to-Thread and a one-to-many relationship with Thread-to-User. models.py class User(db.Model): id = db.Column(db.Integer, primary_key=True) username = db.Column(db.String(32), index=True, unique=True) password = db.Column(db.String(32), index=True) email = db.Column

Spring 3 MVC: one-to-many within a dynamic form (add/remove on create/update)

£可爱£侵袭症+ 提交于 2019-12-17 03:51:11
问题 I'm looking for a solution to manage a one-to-many relation within an HTML form using jQuery . I'm developing with Spring , Spring MVC and Hibernate . I found many tracks on the web, but not any working full-example. The background I've three JPA entities: Consult.java (1) @Entity @Table(name = "consult") public class Consult private Integer id; private String label; private Set<ConsultTechno> consultTechnos; /* getters & setters */ } ConsultTechno.java (2) @Entity @Table(name = "consult

Hibernate: One-To-Many mapping doesn't saved upon update

烈酒焚心 提交于 2019-12-14 03:09:10
问题 I have the following OneToMany relationships between Person and PhoneNumber: class Person { @OneToMany(mappedBy = "person", cascade={CascadeType.PERSIST, CascadeType.MERGE, CascadeType.REMOVE}) @Cascade({org.hibernate.annotations.CascadeType.DELETE_ORPHAN,org.hibernate.annotations.CascadeType.SAVE_UPDATE}) private Set<PhoneNumber> phoneNumbers = new HashSet<PhoneNumber>(); //.... omitted .... } class PhoneNumber { @ManyToOne(optional = false) private Person person; //... omitted ... } If I

Java JPA one to many

被刻印的时光 ゝ 提交于 2019-12-14 01:22:53
问题 I had recently posted someone about populating a JTable, which is now fully functional. How ever, I am stuck over something else now, I'm hoping to achieve two specific thigns with this thread. One is to solve my problem, and the other is to have an answer ready for when others stumble across the same problem, cause I never found a proper answer to this yet. I have the following scenario Two tables: games id pk int genre int title varchar .... genre id pk int name varchar .. One game can only