Do I need elements in persistence.xml?

后端 未结 11 1770
滥情空心
滥情空心 2020-11-22 16:12

I have very simple persistance.xml file:




        
11条回答
  •  挽巷
    挽巷 (楼主)
    2020-11-22 16:44

    The persistence.xml has a jar-file that you can use. From the Java EE 5 tutorial:

    
        
            This unit manages orders and customers.
                It does not rely on any vendor-specific features and can
                therefore be deployed to any persistence provider.
            
            jdbc/MyOrderDB
            MyOrderApp.jar
            com.widgets.Order
            com.widgets.Customer
        
    
    

    This file defines a persistence unit named OrderManagement, which uses a JTA-aware data source jdbc/MyOrderDB. The jar-file and class elements specify managed persistence classes: entity classes, embeddable classes, and mapped superclasses. The jar-file element specifies JAR files that are visible to the packaged persistence unit that contain managed persistence classes, while the class element explicitly names managed persistence classes.

    In the case of Hibernate, have a look at the Chapter2. Setup and configuration too for more details.

    EDIT: Actually, If you don't mind not being spec compliant, Hibernate supports auto-detection even in Java SE. To do so, add the hibernate.archive.autodetection property:

    
      
    
      
        
        
    
        
        
      
    
    

提交回复
热议问题