Hello,
i am currently studying software engineering and so i am exploring Java Enterprise Edition 6.
I have to implement a typical Web Application as of an example ("Book Store") given in Antonio Concalves "Beginning Java EE with Glassfish". The Design Pattern is classical Model View Controller Pattern with a controller class, named queries in the Entity classes, Remote Facade Interface and a GlassFish / DerbyDB Persistence Layer.
By now i have implemented a normal project structure with an EJB and a WAR Module. The WAR Module features an index.xhtml for application startup with two command links and two pages behind them (one for entering a new record and one for displaying data in a GridView).
The page (lets call it createBook) features just some inputText elements and a command button for submitting the record.
Clicking the button triggers an javax.ejb.EJBException. The Stack Trace shows an Unsupported Operation Exception.
it shows:
at $Proxy232.findAllBooksSortedByTitle(Unknown Source)
the Method findAllBooksSortedByTitle is implemented in the facade class. the method calls a named query which is defined in the entity class.
//THE FACADE:
@Stateless
public class BookFacade extends AbstractFacade implements BookFacadeRemote {
@PersistenceContext(unitName = "EntAppBook-ejbPU")
private EntityManager em;
//....
//the method:
@Override
public List findAllBooksSortedByTitle()
{
return this.em.createNamedQuery("findAllBooksSortByTitle", at.rz.entity.Book.class).getResultList();
}
//NAMED QUERY ANNOTATIONS IN THE ENTITY CLASS HEADER:
@Entity
@NamedQueries({
@NamedQuery(name="findAllBooks", query="Select b from Book b"),
@NamedQuery(name="findAllBooksSortByTitle", query="Select b from Book b order by b.title"),
@NamedQuery(name="findAllBooksSortByAuthor", query="Select b from Book b order by b.author.lastName")
})
public class Book implements Serializable
{
//...
}
Now, as you see the naming of query definition and call is not divergent. this cannot be the cause.
so i don´t know how to fix this error.
checking the database shows, that the records have been successfully submitted.
i hope that the professionals around here know help.
Many thanks in advance
roland