Using JAXB to pass subclass instances as superclass
问题 What I have is a set of Java classes (close to 25) representing message types. They all inherit from a Message class which I'd like to be abstract. Each message type adds a few additional fields to the set provided by the Message superclass. I'm implementing some RESTful web services using RESTeasy and would like to have methods like this: public Response persist(Message msg) { EntityTransaction tx = em.getTransaction(); tx.begin(); try { em.persist(msg); } catch (Exception e) { e