facebook

database Schema in Entity class

  1. MyEclipse IDE
  2.  > 
  3. Java EE Development (EJB, JSP, Struts, XDoclet, etc.)
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #300769 Reply

    vitesse
    Member

    I am using JPA with DB2,define database connection in PU,database schema is defined in Entity class’s annotation @Table’s property,but I want the database Schema to be configurable,not hard-coded in code,I want Schema name defined in PU,not code,so I can create Entity Manager from different PU,can I do that? How?
    thanks in advance?

    #300801 Reply

    support-joy
    Member

    vitesse,

    It is possible to configure Schema name from EntityManager class.
    Below mentioned steps is one way to configure schema name from entitymanager.
    1) Remove the attribute “schema” from @Table annotation.
    2) Add <property name=”toplink.jdbc.schema” value=”Your Schema Name” />.By doing this you can create PU’s for each schema.
    3) Now pass the required PU to createEntityManagerFactory() method in EntityManagerHelper.java

    Ex:emf = Persistence.createEntityManagerFactory(“testPU”);

    There might be other different ways to do this too. I would recommend you to investigate over the net.

Viewing 2 posts - 1 through 2 (of 2 total)
Reply To: database Schema in Entity class

You must be logged in to post in the forum log in