composite-primary-key

Hibernate find with composite key. Invalid column name Exception

北慕城南 提交于 2019-12-22 12:40:34
问题 I'm trying to do a Hibernate Find using a composite Primary key but keep getting the following error: Caused by: org.hibernate.exception.SQLGrammarException: Invalid column name 'merchantNumberAccountTypeId'. at org.hibernate.exception.internal.SQLStateConversionDelegate.convert(SQLStateConversionDelegate.java:122) at org.hibernate.exception.internal.StandardSQLExceptionConverter.convert(StandardSQLExceptionConverter.java:49) at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert

Entity Framework mapping two table columns to same related table Key

流过昼夜 提交于 2019-12-22 11:29:30
问题 I'm in a situation where I have a table called Elements . Now I'm creating a table called Divergences that will store basically pairs of Elements . The purpose of Divergence is to check if two Elements have diverging answers. Element Divergence --------- ---------- ElementId ElementId1 ElementId2 In the above table schema, ElementId1 and ElementId2 are Foreign Keys mapping to ElementId in Elements table and form the composite primary key for the Divergence table. I use Database First approach

Don't allow reversed composite primary key in MySQL

試著忘記壹切 提交于 2019-12-20 03:46:47
问题 I'm developing an application which needs to hold data about distances between two cities. I have created a distance table in the Mysql database which holds the name of the two cities and the distance between them. I have made the two town columns a composite primary key. I'd like the database to restrict the application from making duplicated reversed entries like shown on the screenshot to prevent having different distance values. What would be the best solution to solve this problem? 回答1:

Using Hibernate Get with Multi-Column Primary Key

久未见 提交于 2019-12-20 03:10:50
问题 Say I have a class that looks like this: public class MyClass { @Id @Column(name = "ID") private long Id; } I can use a hibernate session to do a get or load on the class like this: MyClass a = (MyClass)session.get(MyClass.class, new Long(100)); However, assume I have a class with multiple columns as the primary key: public MyJoinClass implements Serializable { private static final long serialVersionUID = -5L; @Id @Column(name = "ID") private long id; @Id @Column(name = "EMAIL_ADDRESS_ID")

Working with composite primary key in django project with legacy database

老子叫甜甜 提交于 2019-12-19 08:06:59
问题 I have a legacy database, where some table contains composite primary key. The model I get by running manage.py inspectdb command looks like this. class MyTable(models.Model): field1_id = models.IntegerField(db_column='field1id', primary_key=True) is_favorite = models.BooleanField(db_column='isfavorite', default=False, null=False) is_admin = models.BooleanField(db_column='isadmin', default=False, null=False) role = models.IntegerField(default=USER_GUEST, null=False) field2 = models

Reference to composite primary key in Access 2007

倖福魔咒の 提交于 2019-12-18 08:50:30
问题 I have looked around and found some questions similar but they were for SQL Server instead. Here is a small database structured I have create just to show you the relationships I want to model. Basically it's quite simple, each year has 12 periods and an instance of period-year cannot occur twice (period 9 year 2012 cannot occur more than once ever). So I thought that the best way to model this would be to have a table period with only one field with values from 1-12, a table year following

Why is my EmbeddedId in hibernate not working?

我的未来我决定 提交于 2019-12-18 04:31:33
问题 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

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

谁说我不能喝 提交于 2019-12-17 23:38:48
问题 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

MongoDB and composite primary keys

时间秒杀一切 提交于 2019-12-17 22:12:44
问题 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

spring data rest with composite primary key

十年热恋 提交于 2019-12-17 19:49:46
问题 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