one-to-many

How to get a Builder object from rows related to pivot - Laravel

眉间皱痕 提交于 2019-12-08 03:32:59
问题 I'm trying to get all the "books" that one user have: but I can't do it how I need. I use the following code: /*Gets all books from the user whose id is 1*/ $books= User::find(1)->books(); That return to me an Collection object; but I need a Builder object, as I get when I use the "select" method. /* This code return me a "Builder" object */ Books::select(array('id', 'name', 'type')); I need the Builder instead of Collection because I using Bllim/Datatables on my project and this package just

MongoDB : where is the limit between “few” and “many”?

大城市里の小女人 提交于 2019-12-08 03:18:41
问题 I am coming from the relational database world (Rails / PostgreSQL) and transitioning to the NoSQL world (Meteor / MongoDB), so I am learning about denormalization, embedding and true links. It seems that, in many cases, choosing between various database schemas comes down to the number of documents that will be "related" to each others. In this video series, the author distinguishes: one-to-many relationships from one-to-few relationships many-to-many relationships from few-to-few

One-to many relationship not working - Entity Framework

删除回忆录丶 提交于 2019-12-08 01:57:32
问题 I'm having a problem with creating a one-to-many(or one-to-one?) relationship in entity framework (3.5 I believe). Example tables/models: Settings: SettingsID pk int not null SettingsName varchar(250) null SettingsTypeID fk int null SettingsType: SettingsTypeID pk int not null SettingsTypeName varchar(250) I have a foreign key constraint on Settings.SettingsTypeID that references SettingsType.SettingsTypeID . Upon saving a setting (with a chosen settingstype ) the values save correctly (I

use the one-to-many or many-to-one

跟風遠走 提交于 2019-12-08 01:03:53
问题 Two class: Department Task One department can have many tasks. One task can only belong to one department. So use one-to-many or many-to-one? one-to-many class Department{ private Set tasks; } class Task{ ...... } // Department.hbm.xml .... <set name="tasks"> <key column="departId" /> <one-to-many class="Task" /> </set> ..... many-to-one class Department{ } class Task{ Department depart; } // Task.hbm.xml .... <property name="depart"> <many-to-one class="Department" /> </property> ..... What

Bidirectional @OneToMany relationship with composite pks using SpringBoot and Hibernate

纵饮孤独 提交于 2019-12-08 00:13:48
问题 I have an existing parent-child relationship in our application that has become more complex recently because we have added a "type" column to the primary key of both the parent and the child. After this, adding, reading and modifying children works well but removing them is a pain. Using the advice given in this article by Vlad Mihalcea on @OneToMany relationships and also various examples on the composite keys, I have tried an implementation similar to the following model. However, removing

How to count association size with waterline/sails?

只谈情不闲聊 提交于 2019-12-07 13:33:20
问题 Using sails 0.10.5/waterline 0.10.15: I cannot find an answer to a simple question: how to count the elements of an association without using populate() (which would load all data). Let take a simple many2many relation with via: User: attributes: { following: { collection: 'user', via: 'follower', dominant: true }, follower: { collection: 'user', via: 'following' } Now I need the size of the collections. Currently I try User.findById(1).populateAll().exec(function(err, user) { // count of

Hibernate one-to-many search with Criteria

亡梦爱人 提交于 2019-12-07 11:41:40
问题 I've got a Hibernate entity, called Event, which has a one-to-many metadata entity, EventData. Given the following Event: EventId: 1 EventHash: broccoli With the following EventDatas: EventDataId: 1 EventId:1 Field: tag Content: tagme EventDataId: 2 EventId: 1 Field: tag Content: anotherTag How do I create a Criteria query to retrieve the event which has BOTH tags "anotherTag" and "tagme"? In SQL, I'd join the event_data table once for each tag being searched for, but I can only seem to

Hibernate OneToMany FetchType.LAZY is not working unless accessing the collection?

徘徊边缘 提交于 2019-12-07 09:51:24
问题 I am using spring 4.1.4.RELEASE + hibernate 4.3.6.Final, here is my entity code: public class BaseEntity implements Serializable { } public class MarketInfo extends BaseEntity { @Id @GeneratedValue(strategy = GenerationType.AUTO) @Column(name = "id") private int id; @Column(name = "market_id", unique = true, length = 15) private String marketId; @OneToMany(fetch = FetchType.LAZY, mappedBy = "market") private List<MarketChannelGroup> channelGroups; public List<MarketChannelGroup>

Error: Class …\Entity\.. has no association named

99封情书 提交于 2019-12-07 07:05:11
问题 This question is related to my another question: Doctrine2 gives me only first instance of related objects I came up with bidirectional association to try solve my old issue but now I have another problem. Schema [EDITED] : XYZ\Bundle\CitiesBundle\Entity\Cities: type: entity table: cities fields: id: id: true type: integer unsigned: false nullable: false generator: strategy: IDENTITY name: type: string length: 50 fixed: false nullable: false landarea: type: decimal nullable: false density:

Spring Data Projection with OneToMany returns too many results

独自空忆成欢 提交于 2019-12-07 06:47:55
问题 I have a JPA entity (Person) with onetomany relation (ContactInfo). @Entity public class Person { @Id @GeneratedValue private Integer id; private String name; private String lastname; private String sshKey; @OneToMany(mappedBy = "personId") private List<ContactInfo> contactInfoList; } @Entity public class ContactInfo { @Id @GeneratedValue private Integer id; private Integer personId; private String description; } I've defined a projection interface that includes this onetomany relation as