Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[jakartaee-tck-dev] Puzzling question about a Platform TCK Persistence test with empty string for the persistence unit name, is that defined anywhere as needing to be supported by EE Platform implementations?

https://github.com/jakartaee/platform-tck/blob/10.0.x/src/com/sun/ts/tests/jpa/ee/packaging/ejb/resource_local/persistence.xml#L25 has:

"
<persistence xmlns="https://jakarta.ee/xml/ns/persistence"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="https://jakarta.ee/xml/ns/persistence
    https://jakarta.ee/xml/ns/persistence/persistence_3_0.xsd"
  version="3.0">
    <persistence-unit name="" transaction-type="RESOURCE_LOCAL">
        <non-jta-data-source>jdbc/DB_no_tx</non-jta-data-source>
    </persistence-unit>
</persistence>
"

https://github.com/jakartaee/platform-tck/blob/10.0.x/src/com/sun/ts/tests/jpa/ee/packaging/ejb/resource_local/Client.java#L72 has a test comment that explains why the persistence unit name is empty but the test assertions do not seem to mention the empty name:

"
 /*...
  * EJB-JAR is the root of the persistence unit persistence.xml resides in
   * EJB-JAR META-INF directory The required persistence unit name set to empty
   * string "" which is same as default
   *
   * persistence unit configuration information: EntityManagerFactory looked up
   * via JNDI lookup defined in ejb.xml using persistence-unit-ref descriptor
   * optional unit name, optional description Application-Managed Resource_Local
   * Entity Manager passing in Map of properties Type - RESOURCE_LOCAL -
   * Unit_name should be optional as it only has one PU defined.
   *
   */
"

I remember well that @PersistenceContext + @PersistenceUnit do not have to specify the Persistence unit name as by default it will reference the default persistence unit (e.g. as in the only persistence unit would be typical).

Does anyone have a theory why this test is leaving the persistence unit name empty?  Is that a requirement or only is a requirement because this test is failing if not allowed?

Also for reference from https://jakarta.ee/xml/ns/persistence/persistence_3_2.xsd:

"
<xsd:attribute name="name" type="xsd:string" use="required">
<xsd:annotation>
<xsd:documentation>
Name used in code to reference this persistence unit.
</xsd:documentation>
</xsd:annotation>
</xsd:attribute>
"

Thanks,

Scott


Back to the top