There is a project at apache.org: Common-beanutil, which is a very good tool library for operating JavaBean. It can copy-copy bean attributes, or generate a bird's nest bean. In a dynamic form, I need to generate the table DDL and the JavaBean corresponding to each table from the XML definition file. I can directly generate the defined form definition XML file from the HTML file. use this XML file to generate DDL and dynabean. I created a builder class that generates table DDL and dynabean: Publilc interface builder { Public String buildcreatedddl (string [] systemid) throws sqlexception; Public String builddroppableddl (string [] systemid) throws sqlexception; Public dynabean builddynabean (string [] systemid) throws sqlexception; } In builder implementation, I use XML pull parser to explain the XML file. the DDL and bean structures are consistent. the reason why I need beans is to correspond to the persistent layer to simplify database operations. DDL generation is actually just an implementation method. I can also directly generate HBM. XML file, and then generate the database mode through hibernate. Beanutil plays an important role in generating dyanbean. Each field in the table corresponds to an attribute of the bean. The attributes can be stored in dynaclass, and dynaclass. newinstance can be used to generate dynabean: List list = new arraylist (); Public void processstartelement () {// process each element String name = xpp. getname (); If ("text". Equals (name )) List. Add (New dynaproperties (tablename, String. Class )); } I think it is better to generate HBM. XML to create the database mode, which has the following two advantages: 1) fully utilizes hibernate's powerful o/R Mapping Functions 2) The conversion of table's field types required for DDL creation is not required. Of course, the builder interface needs to be changed properly, but I still don't know, does hibernate need entity to correspond to HBM. xml? Is it possible to integrate with hibernate by using the LS-DYNA entity? This requires further exploration. |