one-to-many

Cross fetch created on bi-directional One-to-many JPA / Hibernate query

拜拜、爱过 提交于 2019-12-13 03:58:17
问题 Here's the basic mapping: Client { @OneToMany(mappedBy="client",cascade=CascadeType.ALL, fetch=FetchType.EAGER) private Set<Group> groups = new HashSet<Group>(); } Group { @ManyToOne (cascade=CascadeType.ALL) private Client client = new Client(); } The problem I'm having is that when I query against Client, I'm getting a full client for each associated group. My queries are pretty simple and I've tried both criteria and HQL. Here's a sample criteria query: Criteria crit = getSession()

Hibernate delete row and foreign key row ManyToOne

拟墨画扇 提交于 2019-12-13 03:57:27
问题 I have the following two classes, one ReqCandAssociation can have many Comments and it is mapped like so. I need to figure out a way that when I delete a ReqCandAssociation it deletes all of its associated comments. Thanks @Entity @Table(name = "candidate_jobReq") public class ReqCandAssociation implements Serializable { @Id private Integer candidateId; @Id private Integer jobId; @Column(name = "reqStatus") private String reqStatus; @ManyToOne @PrimaryKeyJoinColumn(name="candidateId",

MS-Access, form that adds info to a one to many relationship

送分小仙女□ 提交于 2019-12-13 03:44:14
问题 I have a access table with Orders and a sub-table with itemId's. It has one to many relationship. I want to create a form that adds itemId's to a selected order(already existing). This is how i expect it to look like: Order: [ ] ItemId: [ ] Measurement1: [ ] Measurement2: [ ] [Save-button] Can anyone help me with this? 回答1: Subforms are the politically correct way to go IF you want users to have access to the order screen. If users do not need access to the order details directly, only to

ASP.NET MVC 5 - Scaffolding for Many to One Relationship

你离开我真会死。 提交于 2019-12-13 02:23:39
问题 I am Working on ASP.NET MVC 5, EF 6, Razor Engine, VB Language and Database First Approach with VS 2013. Now, in my DB; I have two tables as below: CREATE TABLE [dbo].[Group] ( [Id] INT NOT NULL PRIMARY KEY IDENTITY(1, 1), [Name] VARCHAR(50) NOT NULL ) and CREATE TABLE [dbo].[Subscriber] ( [Id] INT NOT NULL PRIMARY KEY IDENTITY(1, 1), [FirstName] [nvarchar](100) NOT NULL, [MiddleName] [nvarchar](100) NULL, [LastName] [nvarchar](100) NOT NULL, [Email] [varchar] (200) NOT NULL UNIQUE, [GroupId]

How to avoid Hibernate generating two queries for an update with OneToMany?

旧巷老猫 提交于 2019-12-13 01:12:18
问题 I'm facing the same situation as in this question, that has no useful answer. When I add a new element to the many part of my one-to-many relation, Hibernate generates two queries, one to insert and one to update the foreign key to the parent. Why does it need the second query for? Isn't the parent's id set in the insert? Is there any way of avoiding this? Hibernate: /* insert mydomain.LanguageKnowledge */ insert into languageKnowledge (language_fk, level_fk, personId_fk) values (?, ?, ?)

Delete an object from one-to-many relationship

谁都会走 提交于 2019-12-13 00:57:10
问题 Two Entities: Notification User User has an attribute called username There is one-to-many relationship between User <<---> Notification called "users" There is a Notification object (ObjectA) saved that has (2) User Objects saved in the "users" relationship. I would like to update ObjectA by deleting one of the User object in "users" relationship. User entity has an attribute called "username". There are (2) User' s with username "UserA" & "UserB" as objects in the "users" relationship, how

How to create objects that have relationships when using Backand BaaS?

泪湿孤枕 提交于 2019-12-12 19:13:13
问题 I am using Backand BaaS for my ionic app. My model consists of two tables: 1. Users 2. Trips A one-to-many relationship has been established between 'Users' and 'Trips'. 'Users' has a collection field that is a collection of 'Trips' and 'Trips' has a owner field that is an object of 'Users'. What is the correct way to create an object so that upon creating I am assigning the correct owner ('Users' object) to 'Trips' collection field ? 回答1: When POSTing a new Trip use this for the Trip Object

Core Data To-Many Relationship Creating Duplicates When Adding Object to Parent Entity

我的梦境 提交于 2019-12-12 18:28:04
问题 I am new to Core Data and objective-c. I am working on a project where I am taking JSON data from a web service and syncing it with core data. I successfully followed this tutorial and am able to get the JSON into core data without any problem. Where I am having trouble is updating the NSSet associated with a to-many relationship. So far I can get it to update but in doing so its creating duplicate entries in the set. For example, I tried using the Xcode generated access method in my custom

Java, Hibernate java.lang.ClassCastException: org.hibernate.collection.PersistentSet cannot be cast to java.util.HashSet

放肆的年华 提交于 2019-12-12 10:56:22
问题 I have two tables, DVD and Contact. A DVD can be rented to a contact and a contact can rent many DVD's. The many to one link (dvd-->contact) works fine. But the other way fails: (contact-->dvd) This is the contact mapping: <set name="dvds" inverse="true"> <key column="contactId"/> <one-to-many class="Dvd"/> </set> Here is setter getter for Contact: private Set<Dvd> dvds = new HashSet<Dvd>(); public Set<Dvd> getDvds(){ return dvds; } public void setDvds(Set<Dvd> dvds){ this.dvds=dvds; } When I

Get only one (last) record in one-to-many join with linq-to-entities

随声附和 提交于 2019-12-12 10:54:57
问题 I have the following in linq-to-entities clientprojects = (from p in this.SAPMappingEntities.SAP_Master_Projects join c in this.SAPMappingEntities.SAP_Master_ProjectPartners on c.project_no equals p.project_no where c.partner_name.Contains(clientstring) orderby p.start descending select new ClientProjects { client = c.partner_name, location = c.city +", "+c.region, project_no = c.project_no, start_dt = p.start, end_dt = p.finish }).Take(50).ToList(); I would like change this query so that for