composite-key

NHibernate MySQL Composite-Key

I am trying to create a composite key that mimicks the set of PrimaryKeys in the built in MySQL.DB table. The Db primary key is as follows: Field | Type | Null | ---------------------------------- Host | char(60) | No | Db | char(64) | No | User | char(16) | No | This is my DataBasePrivilege.hbm.xml fil...

NHibernate Composite Key

I have created a composite key, and it is working, but ideals I would like the separate directly fields in the row class. The current way I'm doing this is the following: private UserPrimaryKey _compositeKey; public virtual UserPrimaryKey CompositeKey { get { if (_compositeKey == null) _composite...

Alternative for composite key

hi, i have database structure where all the tables are having two columns for primary key. for an example the table Author has two columns like AutherId which is a auto increment number and the pc_id which is unique to that pc the those are the composite keys for the table. but when it comes to relations i have to define the both colum...

How do I map a composite primary key in Entity Framework 4 code first?

I'm getting to grips with EF4 code first, and liking it so far. But I'm having trouble mapping an entity to a table with a composite primary key. The configuration I've tried looks like this: public SubscriptionUserConfiguration() { Property(u => u.SubscriptionID).IsIdentity(); Property(u => u.UserN...

Mixed surrogate composite key insert in JPA 2.0, PostgreSQL and Hibernate 3.5

First off, we are using JPA 2.0 and Hibernate 3.5 as persistence provider on a PostgreSQL database. We successfully use the sequence of the database via the JPA 2.0 annotations as an auto-generated value for single-field-surrogate-keys and all works fine. Now we are implementing a bi-temporal database-scheme that requires a mixed key i...

NHibernate update using composite key

Hi, I have a table defnition as given below: License ClientId Type Total Used ClientId and Type together uniquely identifies a row. I have a mapping file as given below: <hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" auto-import="true"> <class name="Acumen.AAM.Domain.Model.License, Acumen.AAM.Domain" lazy="false" table...

POJOs for Composite Primary Key from Foreign Key

hi, I have table in database that has only two columns and these two colums are FK references. they have made these two colums as composite primarykey. table structure Table A [ A_id PK Description ] Table B [ B_Id PK Description ] Table A_B_Pemissiom [ A_id (FK table A) B_Id (FK table B) Primary...

multi_index composite_key replace with iterator

Is there anyway to loop through an index in a boost::multi_index and perform a replace? #include <iostream> #include <string> #include <boost/multi_index_container.hpp> #include <boost/multi_index/composite_key.hpp> #include <boost/multi_index/member.hpp> #include <boost/multi_index/ordered_index.hpp> using namespace boost::multi_index...

How to identify composite primary key in any Mysql Database table?

How to identify composite primary key in any Mysql Database table? or EDIT 2 what sql query should be used to display the indees of any table who contains the composite primary keys? I have many tables in mysql database which are having composite keys of 2 or 3 primary keys, I am using phpmyadmin, and I have to code a php scr...

Fluent composite foreign key mapping

Hi, I wonder if this is possible to map the following with fluent nhibernate: A document table and a document_revision table will be the target tables. The document_revision table should have a composite unique key consisting of the document_id and the revision number (where the document_id is also the foreign key to the document tabl...

Hibernate Auto-Increment not working

I have a column in my DB that is set with Identity(1,1) and I can't get hibernate annotations to work for it. I get errors when I try to create a new record. In my entity I have the following. @Entity @Table(schema="dbo", name="MemberSelectedOptions") public class MemberSelectedOption extends BampiEntity implements Serializable { ...

LINQ's pathetic handling of composite keys

I have a table that has a composite key that consists of two int fields and one varchar(50) field. I made the composite key my primary key, which I don't usually do. Yes, yes, yes, I'm more than familiar with the logical key vs. surrogate key debate, but I must have done some heavy drugs (not really) the day that I made the table since I...

How to write a custom predicate for multi_index_containder with composite_key?

I googled and searched in the boost's man, but didn't find any examples. May be it's a stupid question...anyway. So we have the famous phonebook from the man: typedef multi_index_container< phonebook_entry, indexed_by< ordered_non_unique< composite_key< phonebook_entry, member<phonebook_entry,std::string,&...

Hibernate MapKeyManyToMany gives composite key where none exists

I have a Hibernate (3.3.1) mapping of a map using a three-way join table: @Entity public class SiteConfiguration extends ConfigurationSet { @ManyToMany @MapKeyManyToMany(joinColumns=@JoinColumn(name="SiteTypeInstallationId")) @JoinTable( name="SiteConfig_InstConfig", joinColumns = @JoinColumn(name="SiteConfigId"), inve...

Is it possible to have a composite id that can be edited in NHibernate?

I have a situation where I have tables that have many columns used as a composite primary key, worse off business logic requires these to be mutable. I am using nhibernate and have no problems mapping for loadig/saving these. However I need to be able to update the property values and have these changes be reflected in the DB when i ...

How can I efficiently compute the MAX of one column, ordered by another column?

I have a table schema similar to the following (simplified): CREATE TABLE Transactions ( TransactionID int NOT NULL IDENTITY(1, 1) PRIMARY KEY CLUSTERED, CustomerID int NOT NULL, -- Foreign key, not shown TransactionDate datetime NOT NULL, ... ) CREATE INDEX IX_Transactions_Customer_Date ON Transactions (CustomerID, Tr...

LINQ-to-SQL join with composite key using "in"

I need to perform a left outer join between two tables using a primary key and an "in" clause. Desired SQL SELECT F.Id, B.Id FROM Foo F LEFT OUTER JOIN Bar B ON B.Id = F.Id and B.Name in ('Spam', 'Eggs') LINQ Query from f in dataContext.GetTable<Foo> join b in dataContext.GetTable<Bar> on f.Id equals b.Id into b1 from b in b1.Defaul...

Normalization is better or composite primary key is better???

Hi, I have a table in Oracle DB,say, Student table. StudentID is the primary key in the table.I have another column interested subjects,say columns name is interested_SUB. A student can have more than one interested subject. In this case, I have the following 2 options: 1) Having the StudentID and Interested_SUB columns as the composite...

Entity Framework CTP4 and composite keys

Hi I was playing with EntityFramework CTP4 and decided to apply it to one of my current projects. The application uses a SQLServer database and there is one table with a composite key. Say, table "MyEntity" has "Key1" and "Key2" as both foreign keys (individually) and as a composite primary key. I made a configuration class derived fro...

Hibernate: Strategy/pattern for object and entity identity mapping using composite keys?

What is a general collision-free Java best practice to generate hash codes for any-type (atomic types) multi-column primary keys? I thought about it for a few hours and came to the conclusion, that a string concatenated by all primary key columns would be the only reliable way to do so. Then calling Java's hashCode method on that concat...