• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Superclass methods not able to acces

 
Ashok Kumar
Greenhorn
Posts: 7
Chrome Linux Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
public class Super implements Serializable {
private Date date;

@Temporal(TemporalType.DATE)
public Date getDate() {
return date;
}

public void setDate(Date date) {
this.date= date;
}

}

Class Sub extends Super{
..other methods
}

I want to do CRUD operation.
When am inserting the values into DB for sub class by setting the superclass POJO
setDate(new Date()).Itz throwing Date column required value to insert.
Is their any relation i have to give?Am in urge ...
 
Ashok Kumar
Greenhorn
Posts: 7
Chrome Linux Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Friends,please help me to resolve this issue in JPA....
 
Mark Spritzler
ranger
Sheriff
Posts: 17276
6
IntelliJ IDE Mac Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You are saying that you are doing

sub.setDate(someDateValueHere);


then

em.persist(sub);

and it gives you the error that the field "date" cannot be null? Plus how are you creating the database field to be called "date" isn't that a reserved word in your database? I am pretty sure it is a reserved word for all database vendors.

Mark
 
Mike Keith
author
Ranch Hand
Posts: 304
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What Mark said is good advice; also, make sure that the superclass is annotated as an entity so that your property is persisted by the provider.
 
Mark Spritzler
ranger
Sheriff
Posts: 17276
6
IntelliJ IDE Mac Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Mike Keith:
What Mark said is good advice; also, make sure that the superclass is annotated as an entity so that your property is persisted by the provider.


Ha, totally missed the @Entity not there on the super class.

Mark
 
Consider Paul's rocket mass heater.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic