Composite Key with Hibernate

后端 未结 4 840
死守一世寂寞
死守一世寂寞 2021-02-15 06:45

In order to generate the next SQL code:

create table users (
    user_name varchar(15) not null primary key, 
    user_pass varchar(15) not null);

create table         


        
4条回答
  •  天命终不由人
    2021-02-15 07:14

    Look in the hibernate docs for the 'composite-id' element. The following may at least give you the intent -- replace your id element with:

    
        
        
    
    

    Note that it's strongly recommended to instead make your ID a separate class ('component') that implements hashCode and equals properly, and that is Serializable. Otherwise you'll have only very awkward ways to lookup your object using session.get() or session.load().

提交回复
热议问题