one-to-one

Django OneToOne reverse relationship does not allow null values

旧城冷巷雨未停 提交于 2019-12-12 01:51:56
问题 I have this architecture (very simplified) from django.db import Models class MainClass(models.Model): a = models.IntegerField() b = models.CharField() class OtherClass(models.Model): c = models.IntegerField() main = models.OneToOneField(MainClass, primary_key=True) Which means my MainClass object has an attribute named otherclass, because of the existence of the reverse relationship between these models . My problem is if I specify valid values for MainClass.a and MainClass.b, but None for

Django ) 'authenticate' with the user model retrieved by the foreign model

╄→гoц情女王★ 提交于 2019-12-12 01:47:45
问题 I'm developing 'email verification' module. First of all, I have a model named 'SNUser' having 'One To One' relationship with the default 'user' model below : class SNUser(models.Model): # Manager objects = SNUserManager() # Auth user = models.OneToOneField(User, unique=True, primary_key=True) I finished sending email containing the unique token for an user. When the link is clicked, I searched the correct SNUser object by the token.(That token is one of the field of SNUser model). So what I

JPA Hibernate null pointer exception with OneToOne primary key/foreign key type relation

不问归期 提交于 2019-12-11 16:08:28
问题 I'm having lots of trouble with a little prototype I'm trying to build. The problem involves two entities. But to understand it, I will need to describe a few others. In terms of the database structure, it can be described as follows: Person ---------------- id Integer PK surname VARCHAR givenNames VARCHAR TypedIdentifier ---------------- idCode VARCHAR PK FK (IdType.code) idVal VARCHAR PK person Integer FK (Person.id) IdType ------ code VARCHAR PK IdDescription ---------- code VARCHAR PK FK

Trouble getting the image out from public folder with a one-to-one relationship

邮差的信 提交于 2019-12-11 15:21:02
问题 I am having some trouble getting the image from the public folder where in the database, I have UserImage table and personal_info table and they are connected together in a one to one relationship. I have tried using this but it just return me blank results. Here are the codes: HomeController: public function getInfo($id) { $data = personal_info::where('id', $id)->get(); $data3 = UserImage::where('user_id', $id)->get(); return view('test',compact('data', 'data3')); test.blade.php (where I

one-to-one mapping in Nhibernate 3

此生再无相见时 提交于 2019-12-11 12:13:01
问题 I have the following classes namespace Extractor.Mapping { public class Application { public virtual Guid Id { get; set; } public virtual string intId { get; set; } virtual SQuery sQuery { get; set; } } } namespace Extractor.Mapping { public class SQuery { public virtual int Id { get;set; } public virtual Guid Application { get;set; } public virtual string Type { get;set; } } } The relation between SQuery and Application is the FK in SQuery named "Application" these are de hbm files

How to identify the mapped/owned sides of a self-referencing one-to-one relationship in Hibernate?

六月ゝ 毕业季﹏ 提交于 2019-12-11 09:56:43
问题 My Hibernate schema has a Port entity. Each Port should have zero or one connections to another Port so there is a "connectedPort" field referencing the same entity: public class Port { // ... @OneToOne @JoinColumn private Port connectedPort; // ... } But normally for a @OneToOne there would be an "owned" side of the relationship and a "mapped" side of the relationship - is this also the case here - and if so, how and why? 回答1: From the OneToOne API doc: If the relationship is bidirectional,

One to One unidirectional mapping with same primary key in hibernate

我只是一个虾纸丫 提交于 2019-12-11 08:53:53
问题 I have two classes/tables (Metafile and RowCount) with a one to one relation. Rowcount only applys to certain metafiles. Currently I have this set up (simplified): MetaFile.java @Entity @Table(name = "file") public class MetaFile { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) @Column(name = "file_id") private int fileId; // getters, setters, constructors... } RowCount.java @Entity @Table(name = "row_count") public class RowCount implements Serializable { @OneToOne @JoinColumn(name=

How do I avoid NullPointerException with OneToOne mapping against a parent entity class?

戏子无情 提交于 2019-12-11 07:52:56
问题 I have searched and found similar issues, but they don't quite seem to be the same problem as Why am I getting this NullPointer exception? OneToOne Mapping with hibernate/JBoss/Seam ANN-613 - NPE when mappedBy property is wrong on a @OneToOne ANN-558 - @OneToMany(mappedBy="") can not recognize properties in parent classes Hibernate Users - NPE with @Id on @OneToOne I have a few entities mapped like this: Person | +--User I want to add a new entity PersonPartDeux with a OneToOne mapping to

Mybatis nested one-to-one or one-to-many relations mapping

泄露秘密 提交于 2019-12-11 06:54:13
问题 I use myBatis to map a simple database (as an example). It consists of 4 models: User , Car , Tariff , Insurance . User has private List carList and private Tariff tariff and some other fields with getters and setters. Car has private Insurance insurance and some other fields with getters and setters. So I can map only 1st nesting level. I mean i can map User and its fields - Tariff and a List of Cars . But I can't map Insurance field of Car . What should I do? Here is my mapper.xml: <?xml

Entity Framework 6.X and one-to-one relationship

為{幸葍}努か 提交于 2019-12-11 06:29:33
问题 I have the following model: public partial class Driver { public string FirstName { get; set; } public string LastName { get; set; } public string Nickname { get; set; } public virtual AspNetUser AspNetUser { get; set; } ...... } public partial class AspNetUser { public string Id { get; set; } public string UserName { get; set; } public virtual Driver Driver { get; set; } ...... } and the following mapping: this.HasOptional(c => c.Driver) .WithOptionalPrincipal(a => a.AspNetUser) .Map(m => m