Win a copy of The Business Blockchain this week in the Cloud forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to get the ID from super class as primary key in derived class using jpa mapping XML

 
Jai Pra
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a supper class which has few variables like ID, name etc. and there is another class which extend the super class.

The base class is defined as a mapped superclass and the derived classes are regular entities. At the class level, the entities extend the base class. The problem is since the id is part of base class(mapped super class) I am not defining it in derived class. On execution it gives an error saying "No identifier defined for the derived class. Please find the code sinpet below:

public class BaseClass {
private long id;

-----
//getters and setters for these fields
}

public class DerivedClass {
private String name;

-----
//getters and setters for these fields
}



<entity-mappings>
<mapped-superclass class="BaseClass">
<attributes>
<id name="id">
<column name="ID" />
</id>
</attributes>
</mapped-superclass>

<entity class="DerivedClass">
<attributes>
<basic name="name">
<column name="NAME"/>
</basic>
</attributes>
</entity-mappings>

Thanks
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic