1

In Hibernate I can define the property named: hibernate.connection.provider_class to declare a class which should be used by Hibernate to create new Connections. This class must implement the interface org.hibernate.engine.jdbc.connections.spi.ConnectionProvider. Is there anything similar in EclipseLink?

The use case behind that is, that I want to wrap jdbc-connections created by a JPA-Provider using a class which allows it to manipulate the statements sent to the JDBC-Driver.

For instance I want to remove sql-hints used in productive code to be able to replace the productive database during tests by H2.

MWiesner
  • 8,868
  • 11
  • 36
  • 70
aschoerk
  • 3,333
  • 2
  • 15
  • 29

1 Answers1

4

According to the official documentation in the EclipseLink JavaDoc (version 2.6.x), you can use:

<property name="eclipselink.jdbc.connector" value="package.MyConnector"/>

in your persistence.xml. By doing so, you can refer to a class MyConnector which has to implement the interface org.eclipse.persistence.sessions.Connector that defines methods which

allow TopLink to acquire a Connection to a JDBC database.

I think, hereby it should be possible to "configure" connections the way you describe it.

FYI: You might extend from org.eclipse.persistence.sessions.DefaultConnector in case you have typical (JDBC) configuration parameters at hand.

Hope it helps.

MWiesner
  • 8,868
  • 11
  • 36
  • 70