Java 获取JTA数据源属性

Java 获取JTA数据源属性,java,hibernate,jpa,Java,Hibernate,Jpa,我想获取我的数据源属性,如用户名或url。 这是我的persistence.xml: <persistence version="2.1" xmlns="http://xmlns.jcp.org/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jc

我想获取我的数据源属性,如用户名或url。 这是我的persistence.xml:

<persistence version="2.1" xmlns="http://xmlns.jcp.org/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd">
    <persistence-unit name="defaulttransaction-type="JTA">
        <jta-data-source>MyDataSource</jta-data-source>
        <exclude-unlisted-classes>false</exclude-unlisted-classes>
    </persistence-unit>
</persistence>
有没有办法做到这一点

我正在使用Hibernate4.3

提前谢谢

someObject.someMethod( ).getProperties( )
// or
someObject.someMethod( ).getProperties( "username" )
// or
someObject.someMethod( ).getUserName( )