Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Create tables in different database schemas using EJB 3 Entity Persistent

 
Jack Bush
Ranch Hand
Posts: 235
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

I would like to find out how to get the following tasks done using EJB 3.0 Java Entity Persistent:

( i ) Create tables in different schemas such as STUDENT under EDUCATION schema and table PATIENT in HOSPITAL schema. We can then reference them in SQL as EDUCATION.STUDENT and HOSPITAL.PATIENT.

( ii ) Reference these tables uniquely once they are created.

There are no pre-existing tables or naming conventions that needs to be adhere to in this situation.

I have no problem creating tables on the current schema in EJB 3.0 Java Entity Persistent.

This question has been posted on http://forums.sun.com/thread.jspa?threadID=5322346 without response so far.

Any suggestions would be appreciated.

Thanks,

Jack
 
Eric Nielsen
Ranch Hand
Posts: 194
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I haven't tried it myself, but the documentation seems to suggest (if using annotations):

and
 
Jack Bush
Ranch Hand
Posts: 235
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Eric,

Thanks for responding back to my call.

What documentation are you referring to?

I will give it a try as well to see whether this is true or not.

Thanks again,

Jack
 
Eric Nielsen
Ranch Hand
Posts: 194
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I found it in the hibernate annotations reference document.


2.2.1.1. Defining the table

@Table is set at the class level; it allows you to define the table, catalog, and schema names for your entity bean mapping. If no @Table is defined the default values are used: the unqualified class name of the entity.
(emphasis added)

This is under the JPA annotations section, not the hibernate extension section.

TopLink seems to have better documentation and it suggests

so I'd try that too...
 
Jack Bush
Ranch Hand
Posts: 235
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Eric,

Yes, you are right and it has worked.

Thanks,

Jack
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic