0

Is it possible to set index of multiple columns while the one of columns is the Primary Key

john Smith
  • 1,565
  • 7
  • 34
  • 54

2 Answers2

0

See this post (googled java hibernate jpa index):

JPA: defining an index column

Specifying an Index (Non-Unique Key) Using JPA

http://www.objectdb.com/java/jpa/entity/index

Then see that (googled java hibernate jpa index composite):

How to define index by several columns in hibernate entity?

Community
  • 1
  • 1
surfealokesea
  • 4,971
  • 4
  • 28
  • 38
  • I know that primary key is already index. my question is if I can put a new index which include two or more columns while one of them is the primary key ? – john Smith Jul 09 '13 at 13:31
  • 2
    @johnSmith: I'm not sure whether you read them through. Last link shows how to define multiple column indexes. It doesn't care whether one of them is primary key or not. You can use it. – GokcenG Jul 09 '13 at 14:56
0

You can do it like this:

<id name="id" type="NumericInteger"> <column name="ID" index="INDEX01"/> </id>

The key is to remove column="ID"  as property of Node <id> and place it as <column> definition instead