Frits Walraven wrote:
Be careful here, none of the JPA implementations I have come across so far have been strict on the JPA specifications. The fact that it works in this JPA implementation is perfectly possible but definitely not portable.
Tim Holloway wrote:You do not need to ORDER BY a selected column. You can not only order by a column not returned by the SELECT, you can order by complex relations.
GROUP BY, however, only works on columns selected for ORDER BY. Otherwise the results would likely contain random "groups" of single records.
K. Tsang wrote:
Only expressions that are derived directly from expressions in the SELECT clause are allowed in the ORDER BY clause
Yet you got no errors is weird. Did you actually get results? Did you check the server log?
Glassfish mandates the objects like Employee to be serializable. But the spec does not mandate it.
According to the spec, the container may be able to serialize some non-serializable objects. Or, the container will use externalization to serialize the non-serializable object.
Setting non-serializable object to null before the stateful bean passivated is just a good practice, but not a must.
Caused by: java.io.IOException
at com.sun.ejb.EJBUtils.serializeObjectFields(EJBUtils.java:746)
at com.ejb._BookServiceImpl_Serializable.writeObject(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at java.io.ObjectStreamClass.invokeWriteObject(ObjectStreamClass.java:988)
at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1495)
at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1431)
at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1177)
at java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1547)
at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1508)
at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1431)
at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1177)
at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:347)
at com.sun.ejb.base.io.IOUtils.serializeObject(IOUtils.java:95)
... 49 more
Caused by: java.io.NotSerializableException: com.domain.Employee
at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1183)
at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:347)
at com.sun.ejb.EJBUtils.serializeObjectFields(EJBUtils.java:744)
... 64 more