Dynamic form: beanutil

Source: Internet
Author: User
Dynamic form: beanutil

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.