Do I need elements in persistence.xml?

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

I have very simple persistance.xml file:




        
11条回答
  •  星月不相逢
    2020-11-22 16:59

    In Java SE environment, by specification you have to specify all classes as you have done:

    A list of all named managed persistence classes must be specified in Java SE environments to insure portability

    and

    If it is not intended that the annotated persistence classes contained in the root of the persistence unit be included in the persistence unit, the exclude-unlisted-classes element should be used. The exclude-unlisted-classes element is not intended for use in Java SE environments.

    (JSR-000220 6.2.1.6)

    In Java EE environments, you do not have to do this as the provider scans for annotations for you.

    Unofficially, you can try to set false in your persistence.xml. This parameter defaults to false in EE and truein SE. Both EclipseLink and Toplink supports this as far I can tell. But you should not rely on it working in SE, according to spec, as stated above.

    You can TRY the following (may or may not work in SE-environments):

    
         false
    
        
                
                
        
    
    

提交回复
热议问题