many-to-one

NHibernate: Many-to-one IUserType

帅比萌擦擦* 提交于 2019-12-11 10:47:48
问题 Following on from this question: NHibernate: Lazy loading of IUserType Seeing as I can't lazy load a property or a one-to-one relationship, is there a way I can use an IUserType with a many-to-one? Something like this (which doesn't work): <many-to-one name="Client" column="`ClientId`" lazy="true" type="EmployeeSystem.UserTypes.ClientUserType, EmployeeSystem" /> 回答1: Looks like NHibernate does not support custom loading ( IUserType ) for associations (many-to-one, one-to-one etc). As a side

Hibernate one-to-many deleting with annotations

自作多情 提交于 2019-12-11 09:30:16
问题 I have a problem with deleting OneToMany and ManyToOne on hibernate. I guess the problem is that I have two parents for a single child. This is how I got it Persona Rol Pais id id id name name name Pais Rol As you can see, the person (persona) is related to the role (rol) and the country (pais). My entities are like this: Person public class Persona implements java.io.Serializable { @ManyToOne(fetch=FetchType.LAZY) @JoinColumn(name="Pais", nullable=false) public Pais getPais() { return this

Odoo how to filter many2one field values in one2many field

馋奶兔 提交于 2019-12-11 05:59:25
问题 I have many2one field name_id . Usually when I use it in my_model.xml code below in this field I can select from all the values written in my.model.line . In this case I want to filter values and see the list of only these values which are written in current my.model. my_model.xml <record model="ir.ui.view" id="view_my_model_form"> <field name="name">my.model.form</field> <field name="model">my.model</field> <field name="arch" type="xml"> <form string="My Model"> <header> <field name="my

Grails table that links to itself

末鹿安然 提交于 2019-12-11 03:19:58
问题 I would like to create a grails domain class that links to itself. This related post suggests a solution but I can't get it to work: Grails domain class relationship to itself For one thing I don’t understand what comparable does and would need to add a int compareTo(obj) method. Adding the following to my code without implementing Comparable compiles, but grails crashes at runtime: //NavMenu parent SortedSet subItems static hasMany = [subItems: NavMenu] static belongsTo = [parent: NavMenu]

play framework 2 ebean @manytoone Column specified twice

安稳与你 提交于 2019-12-10 23:37:30
问题 I'm running to some problems with ebean (using play framework 2 version 2.2.1) I have two classes: my graph class: public class Graph extends Model { @Id @Column(name="id") private String id; @Column(name="type") private String type; @OneToMany(mappedBy="valGraph", cascade=CascadeType.ALL) private List<Val> valItems; and my value class (with Val.graphId foreign key Graph.id): public class Val extends Model @Id @Column(name="valId") private String valId; @Id @Column(name="graphId") private

Hibernate: will merge work with many-to-one object transtively?

你说的曾经没有我的故事 提交于 2019-12-10 11:24:41
问题 Hi I know that and tested before merge will reattach the object back to session preventing lazy initialization exception when object is no longer in session. a.) So I have a few question. If i payment --> customer (in a many-to-one unidirectional relationship) and I do Payment payment = Payment.class.cast(session.merge(oldPayment)); Will customer object also be reattach into session, or do I have to make another merge call for the customer. b.) What happen if the payment--> customer (many-to

Hibernate @ManyToOne remove entry at One side, set FK to NULL at Many side

浪子不回头ぞ 提交于 2019-12-10 11:19:21
问题 I'm trying to learn to work with Hibernate but probably i don't understand @ManyToOne and inverse relations. I have two entities Author and Department . One Author has one Department, One Department has Many Authors. When I remove Author, nothing should happen with Department. When I remove Department, FK in Author's table should be updated to NULL value (Author should NOT be removed). I've found nice explanation of inversion and figured out that Author is an owning side and according to this

Hibernate annotated many-to-one not adding child to parent Collection

柔情痞子 提交于 2019-12-09 03:32:44
问题 I have the following annotated Hibernate entity classes: @Entity public class Cat { @Column(name = "ID") @GeneratedValue(strategy = GenerationType.AUTO) @Id private Long id; @OneToMany(mappedBy = "cat", cascade = CascadeType.ALL, fetch = FetchType.EAGER) private Set<Kitten> kittens = new HashSet<Kitten>(); public void setId(Long id) { this.id = id; } public Long getId() { return id; } public void setKittens(Set<Kitten> kittens) { this.kittens = kittens; } public Set<Kitten> getKittens() {

JPA OneToMany Association from superClass

≡放荡痞女 提交于 2019-12-09 00:13:41
问题 I’m trying to map the inheritance from the superclass LendingLine and the subclasses Line and BlockLine. LendingLine has an ManyToOne association with Lending. When I try to get the LendingLines from the database without the inheritance it works fine. The association works also. But when i add the inheritance, lendingLines in Lending is empty. I also can't get any LendingLines from the DB with the inheritance. Can anybody help me? (Sorry for the bad explanation) Thanks in advance! LendingLine

In JPA, having a many-to-one as primary key throws referential integrity constraint violation

痞子三分冷 提交于 2019-12-08 19:04:27
I have defined the following entities: @Entity public class Child implements Serializable { @Id @ManyToOne(cascade = CascadeType.ALL) public Parent parent; @Id public int id; } @Entity public class Parent { @Id public int id; } When I try to persist a Child with the following code: Parent p = new Parent(); p.id = 1; Child c1 = new Child(); c1.id = 1; c1.parent = p; em.persist(c1); Hibernate throws a 'Referential integrity constraint violation' error: Caused by: org.h2.jdbc.JdbcSQLException: Referential integrity constraint violation: "FK3E104FC802AAC0A: PUBLIC.CHILD FOREIGN KEY(PARENT_ID)