aspose file tools*
The moose likes Object Relational Mapping and the fly likes Superclass methods not able to acces Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Superclass methods not able to acces" Watch "Superclass methods not able to acces" New topic
Author

Superclass methods not able to acces

Ashok Kumar
Greenhorn

Joined: Oct 03, 2007
Posts: 7

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

Joined: Oct 03, 2007
Posts: 7

Friends,please help me to resolve this issue in JPA....
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17260
    
    6

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


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
Mike Keith
author
Ranch Hand

Joined: Jul 14, 2005
Posts: 304
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.


-Mike
Pro JPA 2: Mastering the Java Persistence API
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17260
    
    6

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.
 
subject: Superclass methods not able to acces