composite-primary-key

Why is my EmbeddedId in hibernate not working?

我的未来我决定 提交于 2019-11-29 05:33:16
I have a compound Primary Key (IDHOLIDAYPACKAGE, IDHOLIDAYPACKAGEVARIANT) in table HolidayPackageVariant where IDHOLIDAYPACKAGE refers to entity HolidayPackage with a Many to One relationship between HolidayPackageVariant and HolidayPackage . When I try to do the compund PK mapping in HolidayPackageVariant, I get the following error: Initial SessionFactory creation failed.org.hibernate.annotations.common.AssertionFailure: Declaring class is not found in the inheritance state hierarchy: org.wah.model.holidaypackage.HolidayPackageVariantPrimaryKey Can someone please tell me what am I doing wrong

Hibernate foreign key as part of primary key

老子叫甜甜 提交于 2019-11-29 02:06:16
I have to work with hibernate and not very sure how solve this problem, I've 2 table with a 1..n relationship like this: ------- TABLE_A ------- first_id (pk) second_id (pk) [other fields] ------- TABLE_B ------- first_id (pk)(fk TABLE_A.first_id) second_id (pk)(fk TABLE_A.second_id) third_id (pk) [other fields] How can I manage this with Hibernate??? I don't have idea how to manage the primary key for the second table... There is an example which is completely similar to your case in the Hibernate reference documentation . Just before this example, you'll find the explanations. Here's the

WHERE col1,col2 IN (…) [SQL subquery using composite primary key]

淺唱寂寞╮ 提交于 2019-11-28 21:05:49
Given a table foo with a composite primary key (a,b) , is there a legal syntax for writing a query such as: SELECT ... FROM foo WHERE a,b IN (SELECT ...many tuples of a/b values...); UPDATE foo SET ... WHERE a,b IN (SELECT ...many tuples of a/b values...); If this is not possible, and you could not modify the schema, how could you perform the equivalent of the above? I'm also going to put the terms "compound primary key", "subselect", "sub-select", and "sub-query" here for search hits on these aliases. Edit : I'm interested in answers for standard SQL as well as those that would work with

How to make Primary key Auto increment while using Composite Primary keys in Room persistent library?

橙三吉。 提交于 2019-11-28 19:28:59
I am using Room persistent library. I have requirement to add two primary keys in one table and one of the primary key should be auto increment. I don't know exact syntax to achieve this. Below is my Model class: @Entity(tableName = "newsPapers", primaryKeys = {"news_paper_id","news_paper_name"}) public class SelectNewsModel { private int news_paper_id; @ColumnInfo(name = "image_url") private String imageUrl; @ColumnInfo(name = "news_paper_name") private String newsPaperName; } I want to make "news_paper_id" to be auto incremented. How can i make it? I found another way around for this problem

MongoDB and composite primary keys

这一生的挚爱 提交于 2019-11-28 17:45:51
I'm trying to determine the best way to deal with a composite primary key in a mongo db. The main key for interacting with the data in this system is made up of 2 uuids. The combination of uuids is guaranteed to be unique, but neither of the individual uuids is. I see a couple of ways of managing this: Use an object for the primary key that is made up of 2 values (as suggested here ) Use a standard auto-generated mongo object id as the primary key, store my key in two separate fields, and then create a composite index on those two fields Make the primary key a hash of the 2 uuids Some other

spring data rest with composite primary key

房东的猫 提交于 2019-11-28 11:32:23
I use spring data rest for crud. But when the entity has composite primary keys, I dont know how to to get an entity by giving the primary key. River class: @Entity public class River { private RiverPK id; private Double length; private Timestamp date; private String comment; @Basic @Column(name = "length") public Double getLength() { return length; } public void setLength(Double length) { this.length = length; } @Basic @Column(name = "date") public Timestamp getDate() { return date; } public void setDate(Timestamp date) { this.date = date; } @Basic @Column(name = "comment") public String

JPA/Hibernate: What's better for composite primary keys, @IdClass or @EmbeddedId implementations and why?

ぃ、小莉子 提交于 2019-11-28 10:42:36
what's better for JPA/Hibernate composite primary keys, @IdClass or @EmbeddedId implementations and why? This is an intentionally naive question. I decided to use @EmbeddedId (for whatever reason) and I feel like I made the wrong choice. Dereferencing the embeddedId that contains the column properties is redundant and quite error-prone when coding. Are there any more reasons for and/or against the other? Is the a recommendation by the JPA (spec)? First, if possible, avoid composite ids at all costs. But if you really need, I would recommend @EmbeddedId . @IdClass is basically a leftover from

Laravel Model with Two Primary Keys update [duplicate]

╄→гoц情女王★ 提交于 2019-11-28 04:43:58
This question already has an answer here: How I can put composite keys in models in Laravel 5? 9 answers I'm trying to update Model which has two primary keys. Model namespace App; use Illuminate\Database\Eloquent\Model; class Inventory extends Model { /** * The table associated with the model. */ protected $table = 'inventories'; /** * Indicates model primary keys. */ protected $primaryKey = ['user_id', 'stock_id']; ... Migration Schema::create('inventories', function (Blueprint $table) { $table->integer('user_id')->unsigned(); $table->integer('stock_id')->unsigned(); $table->bigInteger(

Cassandra: choosing a Partition Key

♀尐吖头ヾ 提交于 2019-11-28 04:33:01
I'm undecided whether it's better, performance-wise, to use a very commonly shared column value (like Country ) as partition key for a compound primary key or a rather unique column value (like Last_Name ). Looking at Cassandra 1.2's documentation about indexes I get this: " When to use an index : Cassandra's built-in indexes are best on a table having many rows that contain the indexed value. The more unique values that exist in a particular column, the more overhead you will have, on average, to query and maintain the index. For example, suppose you had a user table with a billion users and

Hibernate foreign key as part of primary key

别来无恙 提交于 2019-11-27 16:26:58
问题 I have to work with hibernate and not very sure how solve this problem, I've 2 table with a 1..n relationship like this: ------- TABLE_A ------- first_id (pk) second_id (pk) [other fields] ------- TABLE_B ------- first_id (pk)(fk TABLE_A.first_id) second_id (pk)(fk TABLE_A.second_id) third_id (pk) [other fields] How can I manage this with Hibernate??? I don't have idea how to manage the primary key for the second table... 回答1: There is an example which is completely similar to your case in