File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/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


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
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: 17249
    
    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: 17249
    
    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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Superclass methods not able to acces
 
Similar Threads
Dynamic Casting to subclass
Constructor
hide vs override
Static Methods
fun with main() and abstract