one-to-one

How to lazy load a one-to-one composition via hql

被刻印的时光 ゝ 提交于 2019-12-22 02:05:22
问题 If have an entity A with a bidirectional one-or-zero-to-one mapping with entity B. The mapping is as follows: <class name="EntityA" table="TABLE_A" mutable="true" lazy="true"> <id name="idA" type="long" column="pk_a" unsaved-value="null"> <generator class="sequence"> <param name="sequence">pk_a_seq</param> </generator> </id> <one-to-one name="propertyB" class="EntityB" property-ref="propertyA" constrained="true" outer-join="false"/> </class> and <class name="EntityB" table="TABLE_B" mutable=

ORM: OneToOne mapping on Non Primary-Key Join column - Book and Inventory mapped by ISBN

偶尔善良 提交于 2019-12-21 12:35:20
问题 I have a Book model and Inventory model mapped by ISBN number, but ISBN is not the primary key in either. Books belong to Bookstores and Inventory is for a group of Bookstores(BookstoreChain). Inventory is shared by all Bookstores belonging to a BookstoreChain. I'm using Hibernate @OneToOne mapping on the book side to fetch inventory info by joining the ISBN column. Somehow, Hibernate generates the left outer join query correctly, but inventory is null on the Book object. Its not lazy loaded

Hibernate JPA one-to-one saving child class entity

◇◆丶佛笑我妖孽 提交于 2019-12-21 02:58:10
问题 I have a one-to-one relationship using PrimaryKeyJoinColumn annotated on the parent side. And now I want to save the child entity by itself. For example, I have Employee and EmpInfo as the child entity, I need to save EmpInfo (of course after setting the id property of the parent to it). However, when such an arrangement is used, I get an exception listed below... org.springframework.dao.InvalidDataAccessApiUsageException: detached entity passed to persist Any ideas why hibernate does not

Django Admin: How to display value of fields with list_display from two models which are in oneToOne relation?

心不动则不痛 提交于 2019-12-20 12:32:20
问题 I belive that the answer to my problem is simple, but I can't find it anywhere. Here is my predicament. I have two models: Member and MemberDetail, which are in oneToOne relation like this: class Member(models.Model): ID = models.AutoField(primary_key=True) FIRST_NAME = models.CharField('First name', max_length=50) LAST_NAME = models.CharField('Last name', max_length=50) def __unicode__(self): return u'%s %s' % (self.FIRST_NAME, self.LAST_NAME) class MemberDetail(models.Model): member =

Hibernate Criteria Return parent record that have one-to-one child record not null?

心已入冬 提交于 2019-12-20 06:39:51
问题 I have a one-to-one relation like this The Parent @JsonAutoDetect @Entity @Table(name = "Parent") public class Parent{ private Integer id; private Child child; @Id @GeneratedValue(strategy= GenerationType.AUTO) @Column (name="idparent") public Integer getId() { return id; } public void setId(Integer id) { this.id = id; } @OneToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "parent") @JoinColumn(name="idchild", nullable=true) public Child getChild() { return child; } public

Hibernate JPA OneToOne orphan removal still not working as of 4.2.7/4.3.0.CR1

白昼怎懂夜的黑 提交于 2019-12-20 02:29:57
问题 Having read JPA 2.0 / Hibernate and "orphanRemoval": Just replacing an entity does not remove the old one, and the related ticket https://hibernate.atlassian.net/browse/HHH-6484, I inferred that this had been (finally) fixed in version 4.2.7 and 4.3.0.CR1. However, trying ... entityManager.getTransaction().begin(); Point point = entityManager.find(Point.class, pointId); point.setPost(null); entityManager.getTransaction().commit(); ... where public class Point { ... @OneToOne(cascade =

NHibernate one-to-one mapping where second table data can be null

孤人 提交于 2019-12-19 05:23:58
问题 I have an existing database with the table Transactions in it. I have added a new table called TransactionSequence where each transaction will ultimately have only one record. We are using the sequence table to count transactions for a given account. I have mapped this as a one-to-one mapping where TransactionSequence has a primary key of TransactionId. The constraint is that there is an instead of trigger on the transaction table does not allow updates of cancelled or posted transactions. So

AspNetUsers' ID as Foreign key in separate table, one-to-one relationship

半城伤御伤魂 提交于 2019-12-18 12:15:53
问题 I have looked up and down, tried all the different and various ways of being able to store a foreign key of the AspNetUser table in a separate Customer table. I'm still new at ASP.NET and the Entity Framework, but I've read quite a few posts and documentations. Currently this is what I have MODELS public class Customer { [Display (Name="Customer ID")] public int CustomerID { get; set; } public string UserId { get; set; } [ForeignKey("UserId")] public virtual ApplicationUser ApplicationUser {

Fluent NHibernate one-to-one doesn't have cascade all-delete-orphan

一个人想着一个人 提交于 2019-12-18 09:03:26
问题 I am in the process of updating the existing *.hbm.xml files into fluent ClassMaps and have stumbled on a mistake in our mapping files, and I don't know the default behavior for me to map this correctly. The mapping file has: <one-to-one name="LineItemAssembly" class="LineItemAssembly" cascade="all-delete-orphan" /> When using Fluent, I would expect this to map to: HasOne<LineItemAssembly>(x => x.LineItemAssembly) .Cascade.AllDeleteOrphan(); However, AllDeleteOrphan() is not an option off of

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