one-to-one

Entity field - queryBuilder->select()

主宰稳场 提交于 2020-01-24 00:21:06
问题 I have a problem with entity field, query builder and OneToOne relationship. When I created entity field with query_builder in form class and when I set select ('u.id, u.username') I get exception: >need array or object, integer given. When I set select('u') is fine but I get columns with OneToOne relationship and Doctrine generates x additional SELECT queries. What do I have to do? EDIT: MORE DETAILS For example I have two entity with oneToOne relation, User and Contact: <?php namespace

JPA - @OneToOne relation on non-primary-key field not working

♀尐吖头ヾ 提交于 2020-01-17 08:19:30
问题 I have a Spring Data JPA backend using Hibernate as the ORM implementation. This is the model: __________ _________________________ |Person | |MailConfig | |________| |_______________________| | id PK | | uid PK-FK(Person.uid) | | uid | | ... | | ... | | | |________| |_______________________| @Entity @Table(name="Person") public class PersonEntity{ @Id private String id; private String uid; @OneToOne(mappedBy="id", fetch=FetchType.EAGER) private MailConfigEntity mailConfigNotes; ... } @Entity

Symfony2 and Doctrine, Column cannot be null with OneToOne relationships

微笑、不失礼 提交于 2020-01-13 17:58:09
问题 Here is an entity ( EDITED: full file content ) // Eve\MoonBundle\Entity\MoonMaterial.php namespace Eve\MoonBundle\Entity; use Doctrine\ORM\Mapping as ORM; //use Doctrine\Common\Collections\ArrayCollection; /** * @ORM\Table(name="_moon_material") * @ORM\Entity() */ class MoonMaterial { public function __construct() { //$this->invTypes_byTypeID = new ArrayCollection(); } // relations start /** * @ORM\OneToOne(targetEntity="Eve\DumpBundle\Entity\invTypes") * @ORM\JoinColumn(name="typeID",

Entity Framework 6: one-to-one relationship with inheritance

喜夏-厌秋 提交于 2020-01-06 20:34:50
问题 I'm using EF6 Code First and here's a simple model which reproduces my issue: abstract class GeoInfo { public int Id { get; set; } public double CoordX { get; set; } public double CoordY { get; set; } } class PersonGeoInfo : GeoInfo { [Required] public Person Person { get; set; } } class CarGeoInfo : GeoInfo { [Required] public Car Car { get; set; } } class Person { public int Id { get; set; } public string Name { get; set; } public virtual PersonGeoInfo PersonGeoInfo { get; set; } } class

Should I divide a table by OneToOneField if the number of columns is too many?

风格不统一 提交于 2020-01-05 07:22:08
问题 I have a student model that already has too many fields including the name, nationality, address, language, travel history, etc of the student. It is as below: class Student(Model): user = OneToOneField(CustomUser, on_delete=CASCADE) # Too many other fields A student has much more information I store in other tables with a OneToOne relationship with the student model such as: class StudentIelts(Model): student = OneToOneField(Student, on_delete=CASCADE) has_ielts = BooleanField(default=False,

Spring Data JDBC invert OneToOne navigation

ⅰ亾dé卋堺 提交于 2020-01-05 05:11:31
问题 I have an existing data scheme I'm reluctant to change. There are two entities/tables: parent and child , with parent having the foreign key column child_id . It's a 1-to-1 relationship. The problem is: the magic behind the scenes expects the child table to have the foreign key column (the exception mentions a ...JOIN ON child.parent = parent.id ). Is it possible to inverse this to match the existing scheme? (I know it is with hibernate, but I'd like to stay with JDBC). Relevant code:

Spring Data JDBC invert OneToOne navigation

我与影子孤独终老i 提交于 2020-01-05 05:11:06
问题 I have an existing data scheme I'm reluctant to change. There are two entities/tables: parent and child , with parent having the foreign key column child_id . It's a 1-to-1 relationship. The problem is: the magic behind the scenes expects the child table to have the foreign key column (the exception mentions a ...JOIN ON child.parent = parent.id ). Is it possible to inverse this to match the existing scheme? (I know it is with hibernate, but I'd like to stay with JDBC). Relevant code:

Does Sqlalchemy really have One to one relationships

守給你的承諾、 提交于 2020-01-04 11:42:02
问题 I have the following scemantic. An alert can have a status change and only one. A status change can have only one alert. A status change can have one reason also a reason can be in maney status changes I tried the following schema class Alert(BaseDb): __tablename__ = 'alerts' __table_args__ = ( PrimaryKeyConstraint('id', name='pk_alerts'), ) id = Column(Integer) alert_text = Column(Text) class AlertStateChange(BaseDb): __tablename__ = 'alert_state_change' __table_args__ = (

Does Sqlalchemy really have One to one relationships

泄露秘密 提交于 2020-01-04 11:40:14
问题 I have the following scemantic. An alert can have a status change and only one. A status change can have only one alert. A status change can have one reason also a reason can be in maney status changes I tried the following schema class Alert(BaseDb): __tablename__ = 'alerts' __table_args__ = ( PrimaryKeyConstraint('id', name='pk_alerts'), ) id = Column(Integer) alert_text = Column(Text) class AlertStateChange(BaseDb): __tablename__ = 'alert_state_change' __table_args__ = (

@OneToOne getting returned as ManyToOneType

流过昼夜 提交于 2020-01-01 19:22:51
问题 I have the following POJO: public class SampleBean1 { @Id @GeneratedValue(generator = "system-uuid") @GenericGenerator(name = "system-uuid", strategy = "uuid") protected String id; @OneToOne(cascade=CascadeType.ALL) @JoinColumn(name="OneToOneID") protected SampleBean1 oneToOne; @OneToMany(cascade=CascadeType.ALL, fetch=FetchType.LAZY) @JoinColumn(name="OneToManyID") protected List<SampleBean1> oneToMany; @ManyToOne(cascade=CascadeType.ALL) @JoinColumn(name="ManyToOneID") protected SampleBean1