简体   繁体   中英

Exception while merge a entity with composite primary key in hibernate

I am using a composite primary key as below,

    @Entity
    public class Mentor implements Serializable {
        private static final long serialVersionUID = 1L;
        @Id
        private MentorPK id;
        private String email;

        public MentorPK getId() {
            return id;
        } 
        //getters and setters
     }

@Embeddable
public class MentorPK implements Serializable {

    private static final long serialVersionUID = 1L;
    private String name;
    private String add;
    //getters and setters
    //override equals and hashcode  
}

I am getting below exception while doing entityManager.merge(mentor)

org.hibernate.exception.SQLGrammarException: ORA-01747: invalid user.table.column, table.column, or column specification

What i am missing here?

Have a look at the description for the error :

You tried to reference a column name, but the column name used is a reserved word in Oracle.

Something you use as a name is a reserved word in Oracle. In this case it seems to be the property name add . Map it to a different column name.

To identify the problematic attribute in cases where you don't easily identify the reserved word activate sql logging, so you get to see the problematic sql statement.

Remove the columns one, by one until the error goes away.

Rename that attribute to something that does not collide with Oracle reserved words

And here is a list of reserved words :

@Entity(name=t_mentor)

t_mentor is your table of database. you need change t_mentor to the table of your database. you need map Class of Mentor to table of database.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM