one-to-one

Hibernate annotations to map one to one unidirectional association with composite primary key

强颜欢笑 提交于 2019-12-24 09:11:10
问题 I have two tables : report and flyleaf. A report is identified by an 'id' and an 'index' which are foreign and primary keys in flyleaf table. The schema of the tables are : CREATE TABLE `report` ( `id` int(11) NOT NULL, `index` varchar(5) NOT NULL, `nb_page` int(11) DEFAULT NULL ); ALTER TABLE `report` ADD PRIMARY KEY (`id`,`index`); CREATE TABLE `flyleaf_t` ( `id` int(11) NOT NULL, `index` varchar(5) NOT NULL, `title` varchar(30) DEFAULT NULL, `author` varchar(30) DEFAULT NULL, `checker`

Entity Framework atypical 1-[0..1] — model-only Association — EF LINQ select possibilities

雨燕双飞 提交于 2019-12-24 08:55:28
问题 Suppose the following tables ParentEntities ParentID ChildEntities ChildID ParentID These tables do not have a FK defined in the schema. In EF designer, after generating from DB, I add an association: - Parent Multiplicity: 1 - Child Multiplicity: 0 or 1 When I build, I get the error: "Error 3027: No mapping specified for the following EntitySet/AssociationSet - ParentChild" But if I try to configure table mapping for the association like this.. Maps to ChildEntities Parent ParentID <->

EF6 Foreign key with one-to-one relationship and two-way property navigation

梦想与她 提交于 2019-12-24 08:07:12
问题 I cannot seem to get EF6 to generate a FK when I am using two-way navigation. Here are my classes (removed some properties for brevity): public class BaseSystem { public int Id { get; set; } public SystemConfiguration Configuration { get; set; } } public class SystemConfiguration { public int Id { get; set; } public BaseSystem System { get; set; } } I want the SystemConfiguration table to have a FK reference back to BaseSystem.Id . Here's my fluent API code: modelBuilder.Entity

Using @OneToOne with Cascade.DELETE in embedded type

跟風遠走 提交于 2019-12-23 14:53:41
问题 In an application I use EclipseLink 2.4.1 with Java Persistence 2.0.4. I have a OneToOne mapping in an embedded class. Everything works fine, except deleting. When I try to delete the object containing the embedded class, the following exception occurs. I checked and I am not calling remove on the embedded object by myself somewhere in the code. Does anybody knows how to avoid this error or how to get around it? Exception [EclipseLink-6002] (Eclipse Persistence Services - 2.4.1.v20121003

hibernate optional join

我只是一个虾纸丫 提交于 2019-12-23 02:31:04
问题 I have an entity mapped with a One-To-One as per the following code: @Entity @Table(name = "my_entity") public class MyEntity { ... @OneToOne @JoinColumn(name = "site_id") private Site site; ... } I've just been told that I must start storing MyEntity entries with a value for 'site_id' which may not exist within the Site table. I still need to store the value for 'site_id' however it will not match a Site entity. The only thing I can think of is to create a 2nd type of Entity mapped to the

Using @OneToOne in PlayFramework 2 / Ebean ORM where the child and parent shares the same primary key

大兔子大兔子 提交于 2019-12-22 17:54:08
问题 There is two models: models/User.java @Entity @Table(name="users") public class User extends Model { @Id public int user_id; public String firstName; public String lastName; @OneToOne @PrimaryKeyJoinColumn public UserProfile profile; public static Finder<Integer,User> find = new Finder<Integer,User>( Integer.class, User.class ); } models/UserProfile.java @Entity @Table(name="user_profiles") public class UserProfile extends Model { @Id public int user_id; public String bio; @OneToOne(mappedBy

Using @OneToOne in PlayFramework 2 / Ebean ORM where the child and parent shares the same primary key

与世无争的帅哥 提交于 2019-12-22 17:53:01
问题 There is two models: models/User.java @Entity @Table(name="users") public class User extends Model { @Id public int user_id; public String firstName; public String lastName; @OneToOne @PrimaryKeyJoinColumn public UserProfile profile; public static Finder<Integer,User> find = new Finder<Integer,User>( Integer.class, User.class ); } models/UserProfile.java @Entity @Table(name="user_profiles") public class UserProfile extends Model { @Id public int user_id; public String bio; @OneToOne(mappedBy

Django - one-to-one modelAdmin

可紊 提交于 2019-12-22 17:38:12
问题 I am moderately proficient with django and trying to use model forms for an intranet project. Essentially, I have a "Resources" model, which is populated by another team. Second model is "Intake", where users submit request for a resource. It has one-to-one mapping to resource. Objective is to only allow 1 resource allocation per intake. Now, Intake model form shows the form, with a drop-down field to resource, with a caveat that it shows all resources, regardless of previous allocation or

SQLAlchemy one-to-one relation, primary as foreign key

戏子无情 提交于 2019-12-22 05:12:42
问题 I am mapping classes to existed MySQL tables generated by Drupal. I need to relate to tables(one-to-one), but I've got a problem. Two tables have the column nid. Both fields are primary keys. I can not define foreign key without a primary key. And relation map is not applied to a primary key. My version is below. class Node(Base): __tablename__ = 'node' nid = Column(Integer, primary_key=True) vid = Column(Integer) uuid = Column(String(128)) type = Column(String) field_data = relationship(

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

≯℡__Kan透↙ 提交于 2019-12-22 02:06:06
问题 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=