aspose file tools*
The moose likes Object Relational Mapping and the fly likes Create tables in different database schemas using EJB 3 Entity Persistent    Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Create tables in different database schemas using EJB 3 Entity Persistent    " Watch "Create tables in different database schemas using EJB 3 Entity Persistent    " New topic
Author

Create tables in different database schemas using EJB 3 Entity Persistent

Jack Bush
Ranch Hand

Joined: Oct 20, 2006
Posts: 235
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

Joined: Dec 14, 2004
Posts: 194
I haven't tried it myself, but the documentation seems to suggest (if using annotations):

and
Jack Bush
Ranch Hand

Joined: Oct 20, 2006
Posts: 235
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

Joined: Dec 14, 2004
Posts: 194
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

Joined: Oct 20, 2006
Posts: 235
Hi Eric,

Yes, you are right and it has worked.

Thanks,

Jack
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Create tables in different database schemas using EJB 3 Entity Persistent