- A Framework for Java/XML binding based on SAX2 -
One of JaxMe's source generators is the BeanWriter, which creates J2EE conformant entity beans for EJB (Enterprise JavaBeans) with BMP (Bean Managed Persistence) or stateless session beans. In this documents we'll discuss the BeanWriter's details.
The BeanWriter's usage
The BeanWriter is used just like any other SourceWriter:
java -classpath xerces.jar;jaxme.jar de.ispsoft.jaxme.generator.Main --schemaReader=de.ispsoft.jaxme.generator.XsdJdbcSchemaReader --sourceWriter=de.ispsoft.jaxme.generator.JavaSourceWriter --sourceWriter=de.ispsoft.jaxme.generator.BeanWriter examples/session/schema.xsdWhen running this example, you will find that some additional files are being generated in the directory de/ispsoft/jaxme/examples/session besides the usual ClsSession, ClsSessionHandler and ClsSessionManager:
The BeanWriter has created an entity bean, because the structure was specified by reading a table definition. In other words, because data can not only be read, but also inserted, updated or deleted. If the structure would be specified with a JaxMe view, then it would have created a session bean instead. The session bean could only read data.
The BeanWriter's target is a compromise between performance and encapsulation. It is best used with the following in mind:
Generated entity beans should have proper
findByName(String pName); findByZip(String pZip);and so on. You can specify these find methods together with the specification of the mapped tables, see the section on Find methods in the generated manager for details.
Session beans, that are generated from JaxMe views, can have
similar methods, which are called
Compatibility with EJB 1.1
By default the BeanWriter creates sources as specified by EJB 2.0.
However, in a few cases these are incompatible with EJB 1.1. In
particular the constructor
If you specify the option
java -classpath xerces.jar;jaxme.jar de.ispsoft.jaxme.generator.Main --schemaReader=de.ispsoft.jaxme.generator.XsdJdbcSchemaReader --sourceWriter=de.ispsoft.jaxme.generator.JavaSourceWriter --sourceWriter=de.ispsoft.jaxme.generator.BeanWriter --option=ejb11compatible=true examples/session/schema.xsd