Ejb3? Entity? Bean configuration file persistence. xml

Source: Internet
Author: User
Tags jboss server
The persistence. xml file is to be packaged into the META-INF directory of the ejb jar file. The persistence. xml file is used to specify the data source used by the object bean and the default behavior of the entitymanager object. Persistence. the configuration of the XML file is described as follows: <persistence> <persistence-unit name = "foshanshop"> <JTA-data-source> JAVA: /defaultmysqlds </JTA-data-source> <Properties> <property name = "hibernate. hbm2ddl. auto "value =" Create-drop "/> </Properties> </persistence-unit> </persistence> one or more persistence-unit nodes, each persistence-unit node defines the persistent content name, data source used, and persistence product proprietary attributes. The name attribute defines the persistence name. The JTA-data-source node specifies the JNDI name of the data source used by the object bean. Released on JBoss The data source name must contain Java :/ PrefixThe data source name is case sensitive. The properties node is used to specify the attributes of the persistence product, Different application servers use different persistence products.For example JBoss Use Hibernate , Weblogic10 Use Kodo , Glassfish/Sun Application Server/oralce Use Toplink. Because JBoss uses hibernate, Hibernate has a property. hbm2ddl. auto: Specifies whether to synchronize the database structure when the entity bean is released. If hibernate. hbm2ddl. the value of auto is set to create-drop. The corresponding database table is automatically created and deleted when the entity bean is released and detached (note: when the JBoss server is started or shut down, the release and uninstallation of the Entity Bean will also be triggered ). The toplink. DDL-generation attribute of the toplink product also plays the same role.

TIPS: If your table already exists and you want to retain data, you can use hibernate to publish the object bean. hbm2ddl. auto is set to none or update. We recommend that you use update to update the data table for future changes to the object bean. In this way, the corresponding fields can be added to the data table when an attribute is added to the object bean.

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.