one-to-many

Two attributes sharing the same OneToMany relationship to one entity Symfony2

不想你离开。 提交于 2019-12-05 08:34:41
Let's first describe my situation. I am using Symfony2 and I have a problem with a relationship between my entities. I have two entities that are linked together. The two entities are AssociationQuestion and AssociationPossibleAnswer . I am currently creating a questionary software where one would have to link one possible answer on the left to another one possible answer on the right, such as in the following example: Currently, I'm planning on having two attributes that are arrays in class AssociationQuestion that would hold many AssociationPossibleAnswer objects. The first array would

CoreData to-many add error

▼魔方 西西 提交于 2019-12-05 08:10:50
Not sure what I'm doing wrong here. School has a to-many to Student, and Student has its inverse. A little test code as follows: @class Student; @interface School : NSManagedObject @property (nonatomic, retain) NSString * name; @property (nonatomic, retain) NSOrderedSet *students; @end @interface School (CoreDataGeneratedAccessors) - (void)insertObject:(Student *)value inStudentsAtIndex:(NSUInteger)idx; - (void)removeObjectFromStudentsAtIndex:(NSUInteger)idx; - (void)insertStudents:(NSArray *)value atIndexes:(NSIndexSet *)indexes; - (void)removeStudentsAtIndexes:(NSIndexSet *)indexes; - (void

How to render one to many relationships to XML with PostgreSQL

我们两清 提交于 2019-12-05 07:02:00
I have several many to many relationships in my schema. For example, a package has many taskgroups, taskgroups in turn have many tasks. All tables are linked together via many to many tables, holding for instance the primary key of package and the primary key of taskgroup. (I know this is not strictly needed, since XML is one to many, but I couldn't think of a better structure). Is it possible to get the query result as XML, reflecting the one-to-many structure? So, the result should be like this: <package id=1> <taskgroup id=1> <task id=1> <task id=2> </taskgroup> <taskgroup id=2> <task id=3>

JPA 2.0 Hibernate @OneToMany + @MapKeyJoinColumn

流过昼夜 提交于 2019-12-05 06:27:17
OneToMany + MapKeyJoinColumn doesn't work for me, please suggest what I'm doing wrong. I'm using JPA 2.0 + Hibernate 3.6.1 And want to map following tables: To Classes: @Entity public class Question { // id and other fields @OneToMany(mappedBy="question", cascade = CascadeType.ALL) @MapKeyJoinColumn(name="language_id") private Map<Language, Statement> statements = new HashMap<Language, Statement>(); } @Entity public class Statement { @Id private Long id; @ManyToOne @JoinColumn(name = "language_id", nullable = true) private Language language; @ManyToOne @JoinColumn(name = "question_id",

spring rest lazy loading with hibernate

我的未来我决定 提交于 2019-12-05 03:14:37
问题 I am trying to develop spring rest api with hibernate. after searching in google, I have not find solution to lazy loading. I have two entity like below: University.java @Entity() @Table(schema = "core", name = "university") public class University extends BaseEntity { private String uniName; private String uniTelephon; @LazyCollection(LazyCollectionOption.FALSE) @OneToMany(fetch = FetchType.LAZY, mappedBy = "university", cascade = CascadeType.ALL) @JsonManagedReference private List<Student>

JPA/Hibernate bidirectional many-to-one results in StackOverflowException

◇◆丶佛笑我妖孽 提交于 2019-12-05 03:04:52
I have entities User and GrantedRole that have a bidirectional one-to-many relation. When I try to add a GrantedRole to the Set in User, there is no exception thrown, but when I debug the variables for the User and GrantedRole object have a description that reads com.sun.jdi.InvocationException occurred invoking method. The different fields for the variables can be read while debugging, but when I select the roles field in User or the user field in GrantedRole I get the same description as above. When I go into the Set of GrantedRole in user, I eventually find the following description: Detail

Null foreign key, in ManyToOne relation using hibernate [4.1.1] annotations

二次信任 提交于 2019-12-05 02:52:37
问题 I am trying to persist a one-to-many and a many-to-one relation using Hibernate 4.1.1 but the foreign key is always NULL . There are two entities: Account and Client . A Client could have multiple Accounts while an Account has exactly one Client . Here are the classes (only what matters): Account.java @Entity @Table(name = "account") public class Account implements Serializable { private Client client; @Id @GeneratedValue(strategy = GenerationType.AUTO) @Column(name = "id") public long getId(

Symfony2: Warning: spl_object_hash() expects parameter 1 to be object, integer given

不羁岁月 提交于 2019-12-05 00:20:58
问题 I have a many to one relationship between the entities Project and Course because each course can have many projects so many projects could be related to the same course. These are my entities: class Project{ /** * @ORM\Id * @ORM\Column(type="integer") * @ORM\GeneratedValue(strategy="AUTO") */ protected $id; //... other fields ... //----------------------- DATABASE RELATIONSHIP ----------------// //PROJECT-COURSE - M:1 relationship /** * @ORM\ManyToOne(targetEntity="Course", inversedBy=

Hibernate: bi-directional one-to-many with one as parent

耗尽温柔 提交于 2019-12-05 00:16:38
问题 I'm trying to setup a bi-directional one-to-many relationship with "one" as parent I have a parent: @Entity public class VideoOnDemand { @OneToMany(cascade = CascadeType.ALL) @LazyCollection(LazyCollectionOption.FALSE) @JoinColumn(name = "video_id") private List<CuePoint> cuePoints = new ArrayList<CuePoint>(); } and a child: @Entity public class CuePoint { @ManyToOne(cascade=CascadeType.ALL) @JoinColumn(name = "video_id", insertable = false, updatable = false) private VideoOnDemand video; } I

saving pictures in Core Data in 'to-many relationship' environment

早过忘川 提交于 2019-12-04 22:33:18
I'm working on my small project which take pictures and save them, very simple, using Core Data. I have two entities; one is 'Person' and the other is 'Image'. the relationship from Person to Image is to-many and from Image to Person I got inverse relationship as well. All I need at the moment is to add multiple number of images (taken from iphone camera or chosen from library) to one Person entity . I'd like to know whether there is any kind of sample code that deals with to-many relationship with UIImage using Core Data. many thanks. ===================== Actually I wish I could specify the