Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [eclipselink-users] Persistence.xml file

Depending on how you are deployed, EclipseLink will get the list of classes in different ways.

1. If you are in a Java EE container. The container will provide them by default and you do not need the exclude-unlisted-classes tag.

2. In Java SE, we try to find them for you by asking the classloader for the "META-INF/persistence.xml" resource, truncate the "META-INF/persistence.xml" part of the URL and use that as the base for our search

- If the persistence unit is in a jar file, we build a JarFile instance and search the entries in the jar file - If the persistence unit is a directory we use java.io.File API to navigate down the directory structure

If you want to see how the implementation works, the code is in our org.eclipse.persistence.jpa component in the org.eclipse.persistence.internal.jpa.deployment package.

One thing to remember is based on the specification, portable applications in Java SE are expected to list the classes. Our Java SE strategy works for quite a lot of users, but it is possible to find web containers where we do not get enough information to properly search - in that case, the classes need to be listed.

-Tom
krisusa123 wrote:
Hello EclipseLinkTeam
I have my eclipselink persistence.xml file listed as below.
How does the application find all the entities without being specified with <class></class> tags in my peristence.xml file? What does <exclude-unlisted-classes> does? Thanks in advance!
<?xml version=/"1.0"/ encoding=/"UTF-8"/?>

<persistence version=/"1.0"/ xmlns=/"http://java.sun.com/xml/ns/persistence"/ xmlns:xsi=/"http://www.w3.org/2001/XMLSchema-instance"/ xsi:schemaLocation=/"http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"/>

<persistence-unit name=/"Testing"/ transaction-type=/"RESOURCE_LOCAL"/>

<exclude-unlisted-classes>false</exclude-unlisted-classes>

</persistence-unit>

</persistence>
All the other properties are populated at run time using syntax like this
properties.put(PersistenceUnitProperties./TARGET_DATABASE/,

PropertyManager./getProperty/("persistence.target_database"));

f u cn rd ths, u cn gt a gd jb n cmptr prgrmmng



------------------------------------------------------------------------

_______________________________________________
eclipselink-users mailing list
eclipselink-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/eclipselink-users


Back to the top