Create tables in different database schemas using EJB 3 Entity Persistent

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.
Any suggestions would be appreciated.
Thanks,
Jack

Use the schema attribute of the Table annotation:
package javax.persistence;
@Target({TYPE}) @Retention(RUNTIME)
public @interface Table
   String name( ) default "";
   String catalog( ) default "";
   String schema( ) default "";
   UniqueConstraint
uniqueConstraints( ) default {};
}

Similar Messages

  • How do you join two tables from different Oracle schemas using a subquery

    I am trying to join two tables from different Oracle schemas using a subquery. I can extract data from each of the tables without a problem. However, when I combine the select statements using a subquery I get the Oracle error *'ORA-00936: missing expression'*. Since each SELECT statement executes on its own without error I don't understand what is missing. The result set I am trying to get is to match up the LINE_ID from PDTABLE_12_1 in schema DD_12809 with the MAT_DESCRIPTION from table PDTABLE_201 in schema RA_12809.
    The query is as follows:
    sql = "SELECT [DD_12809].[PDTABLE_12_1].LINE_ID FROM [DD_12809].[PDTABLE_12_1] JOIN " _
    + "(SELECT [RA_12809].[PDTABLE_201].MAT_DESCRIPTION " _
    + "FROM [RA_12809].[PDTABLE_201]) AS FAB " _
    + "ON [DD_12809].[PDTABLE_12_1].PIPING_MATER_CLASS = FAB.PIPING_MATER_CLASS"
    The format of the query is copied from a SQL programming manual.
    I also tried executing the query using a straight JOIN on the two tables but got the same results. Any insight would be helpful. Thanks!
    Edited by: user11338343 on Oct 19, 2009 6:55 AM

    I believe you are receiving the error because you are trying to JOIN on a column that doesn't exist. For example you are trying to join on FAB.PIPING_MATER_CLASS but that column does not exist in the subquery.
    If you want to do a straight join without a subquery you could do the following
    SELECT  DD_12809.PDTABLE_12_1.LINE_ID
    ,       FAB.MAT_DESCRIPTION
    FROM    DD_12809.PDTABLE_12_1
    JOIN    RA_12809.PDTABLE_201    AS FAB ON DD_12809.PDTABLE_12_1.PIPING_MATER_CLASS = FAB.PIPING_MATER_CLASS  HTH!

  • How can i create table between different servers schema

    Hi,
    Can any advice me how I can create table on remote oracle schema.
    Thanks in advance
    Faheem Latif

    I am telling you what I know about remote table creation - it is impossible in Oracle, if you trust the documentation of course.
    ORA-02021: DDL operations are not allowed on a remote database
    Cause:     An attempt was made to use a DDL operation on a remote database. For example, "CREATE TABLE tablename@remotedbname ...".
    Action:     To alter the remote database structure, you must connect to the remote database with the appropriate privileges.

  • Updating a table of different database user using  db links

    Consider two databases
    db10gA and db10gB which is having a db link from A to B
    There is a user A in db10gA
    and another user B in db10gB
    the user require to insert,update,delete records of user B tables
    so how is the DML privileges are granted to user A to perform these tasks at db10gB database
    whether it is the type of db link decides to do these tasks
    whether any synonym created at db10gA side might help to do the job

    user7993571 wrote:
    Consider two databases
    db10gA and db10gB which is having a db link from A to B
    There is a user A in db10gA
    and another user B in db10gB
    the user require to insert,update,delete records of user B tables
    so how is the DML privileges are granted to user A to perform these tasks at db10gB database
    whether it is the type of db link decides to do these tasks
    whether any synonym created at db10gA side might help to do the jobUser A will act on behalf of the user who has created the DBLINK; for example if you have created the DBLINK with a user having a DBA role; and grant the DBLINK access to A, A can act on behalf of the DBA who has created the DBLINK.

  • How to create a view consisting of data from tables in2 different databases

    Using Oracle 10.2g
    I have 2 databases Gus and haggis on Comqdhb schema.
    glink indicates a databse link between Haggis and Gus
    In Gus there are tables student,subject,grade,school containing columns like upn...
    STUDENT
    upn
    academicYear
    SUBJECT
    subject
    GRADE
    examlevel
    grade
    SCHOOL
    sn
    In HAGGIS there are tables student,grade,teacher containing columns upn...desc below.
    STUDENT
    upn
    GRADE
    grade
    upn
    academicyear
    level
    Create view in your HAGGIS database which will join all of the exam grades together. You should have one view which will produce the following relation :
    examGrade(upn, subject, examlevel, sn, grade,academicYear)
    so I need to create a view which gets the data from both the tables in both the databases.
    create view as examGrade(upn, subject, examlevel, sn, grade,academicYear) as select s.upn
    But i am not getting how to select a column from 2 tables in different databases
    I mean if i said
    select upn from comqdhb.student@glink,comqdhb.student;
    select upn from comqdhb.student@glink,comqdhb.student
    ERROR at line 1:
    ORA-00918: column ambiguously defined
    help me out,Thank you.

    Thank you for the reply will follow up the code format
    Create views in your HAGGIS schema database which will join all of the exam grades together. You should have one view which will produce the following relation :
    examGrade(upn, subject, examlevel, sn, grade,academicYear)
    I understand that there wont be duplication when we use conditions
    If i query
    select count(upn)
    from   comqdhb.student@glink I get 9000
    but after the union
    create view examGrade(upn, subject, examlevel, sn, grade,academicYear)
    as
    select distinct s.upn as upn
    ,                  g.subject as subject
    ,                  g."LEVEL" as examlevel
    ,                  g.grade as grades
    ,                  '9364097'
    ,                  to_number(g.academicyear) as academicyear
    from             comqdhb.student s
    ,                   comqdhb.grade g
    where           s.upn=g.upn
    union
    select            s.upn
    ,                   sb.subject
    ,                   g.elevel
    ,                   g.grade
    ,                   s.acyr
    ,                   sc.sn
    from              comqdhb.subject@glink sb
    ,                   comqdhb.student@glink s
    ,                    comqdhb.gradevalues@glink g
    ,                    comqdhb.school@glink sc,
    ,                    comqdhb.studentingroup@glink sg
    ,                    comqdhb.teachinggroup@glink tg
    where            sb.sid=tg.sid
    and                tg.gid=sg.gid
    and                sg.upn=s.upn
    and                g."LEVEL"=tg.elevel
    and                s.school=sc.id
    and                sc.id=tg.id; returns
    count(upn) from exam gradeIt gets stuck actually sometimes it returns
    932002 some results.
    2:
    Another problem i am having which i am trying to solve and written up my ideas but haven't been getting the expected results.Hope you can help.Thank you.
    Information:
    =======
    All children take exams at the age of 16 called a General Certificate of SecondaryEducation (GCSE).
    They have to study and take exams in Mathematics, English and Science, and can take other subjects such as History, French, Art etc. Most students will study between 5 and 10 different subjects before taking their GCSEs.
    For each exam, a student is awarded a grade from A*, A, B,C,D,E,F,G,U,X An A* grade is the best grade achievable and an X is the worst grade.
    In order to analyze how students have performed, each grade is mapped to a numeric value as follows:
    Grade Numerical score
    A* 8
    A 7
    B 6
    C 5
    D 4
    E 3
    F 2
    G 1
    U 0
    X 0
    Now why i need this avgGCSE is because i have to create a view containing avgGCSE of the students it is used in the next question where a condition is avgGCSE is between 6.5 and 7
    In order to calculate the avgGCSE the idea is to calculate the grades of the students and map the grades to their corresponding scores/values
    add them all up and div by the total no of grades to get the avg.
    desc comqdhb.STUDENT@glink;
    STUDENT
    =======
    UPN
    FNAME
    CNAME
    DOB
    GENDER
    PREVIOUSSCHOOL
    XGCSE
    SCHOOL
    ACYR
    STUDENTINGROUP
    =============
    UPN
    GID
    STARTDATE
    ENDDATE
    GRADE
    GRADEVALUES
    ===========
    GRADE
    LEVEL
    VALUE
    I have a opinion that xgcse in STUDENT table refers to the avgGCSE which i want to calculate as when i asked my professor as to what xgcse he said that he forgot to take it out of the table and it is not necessary while creating avggcse.
    select *
    from comqdhb.student@glink
    where xgcse<6.5; Displaying a result
    returns:
    UPN FAMILYNAME COMMONNAME DATEOFBIR GENDER PREVIOUSSCHOOL XGCSE SCHOOL ACYR
    ===========================================================================
    1011 KIMBERLY ABBOT 07-JUL-79 f none 3.93500948 2 2
    select *
    from comqdhb.student@glink
    where xgcse between 6.5 and 7 and upn = 1386; Displaying a result
    returns:
    UPN FAMILYNAME COMMONNAME DATEOFBIR GENDER PREVIOUSSCHOOL XGCSE SCHOOL ACYR
    ===========================================================================
    1386 STEPHANIE AANNESSON 15-JAN-79 f none 6.88873 2 2 so if xgcse is the avgGCSE then upn 1011 has avggcse<6.5 and 1386 has avggcse >6.5
    my idea was backward strategy like so now if we find out upn 1368 has suppose xgcse(avggcse)>6.5 how to extract the avggcse for the particular upn We need to map grades from GRADEVALUES to grade in STUDENTINGROUP and map upn from studentingroup to upn in student to output the values for the corresponding grades from GRADEVALUES
    select grade
    from comqdhb.studentingroup@glink
    where upn = 1011;
    Result:
    GRADE
    =====
    D
    F
    B
    E
    C
    E
    E
    B
    8 rows selected. Mapping each grade to the corresponding value and calculating we get
    32/8=4 total(values to corresponding grades)/no of grades.
    But the xgcse for upn 1011 is 3.935 and i am getting 4!! maybe xgcse isn't avggrade but ? is the procedure by me correct for calculating avggcse
    select grade
    from comqdhb.studentingroup@glink
    where upn = 1386;
    Result:
    GRADE
    ======
    A*
    A*
    A*
    A*
    B
    A*
    A*
    A
    B
    B
    B
    11 rows selected. grade to the corresponding value and calculating we get
    79/11=7.12 total(values to corresponding grades)/no of grades.
    But the xgcse for upn 1011 is 6.88... and i am getting 7.12!!
    But another problem
    when i say
    select   g.value,g.grade
    from     comqdhb.gradevalues@glink g
    ,        comqdhb.studentingroup@glink sg
    where    g.grade=sg.grade
    and      sg.upn=1011;
    result:
    ======
    VALUE GRADE
    ===========
      100 B
      100 B
       80 C
       60 D
       40 E
       40 E
       40 E
       20 F
        6 B
        6 B
        5 C
    VALUE GRADE
    =============
        4 D
        3 E
        3 E
        3 E
        2 F
    16 rows selected.
    select   distinct g.value,g.grade
    from     comqdhb.gradevalues@glink g
    ,        comqdhb.studentingroup@glink sg
    where    g.grade=sg.grade
    and      sg.upn=1011;
    result:
    ======
    VALUE GRADE
    ============
         2 F
       100 B
         6 B
         3 E
        60 D
         5 C
         4 D
        80 C
        40 E
        20 F
    10 rows selected. I am getting only 8 for the query
    select grade
    from comqdhb.studentingroup@glink
    where upn = 1386; here its becomming 10 and also its displaying values as 100 and ...
    select distinct *
    from   comqdhb.gradevalues@glink;
    GRADEVALUES
    ===========
    LEVEL      GRADE           VALUE
    ================================
    a          A                 120
    a          B                 100
    a          C                  80
    a          D                  60
    a          E                  40
    a          F                  20
    a          U                   0
    a          X                   0
    g          A                   7
    g          A*                  8
    g          B                   6
    LEVEL      GRADE           VALUE
    ================================
    g          C                   5
    g          D                   4
    g          E                   3
    g          F                   2
    g          G                   1
    g          U                   0
    g          X                   0
    18 rows selected. I was hoping if i could map the grades and get the values and calculate avggrade by total(values)/count(values)that would be it but here there are values like 100...
    select  sum(g.value)/count(g.grade) as avggrade
    from    comqdhb.gradevalues@glink g
    ,         comqdhb.studentingroup@glink sg
    where  g.grade=sg.grade
    and     sg.upn=1386;
    avggrade
    ========
    37.4375 the avggrade cant be this big and when i map each grade i obtained for 1368 like a to 7+b to 6 so on i get avggrade 7.12
    kindly help.
    Edited by: Trooper on Dec 15, 2008 4:49 AM

  • Create Foreing Key to one table in different dataBase

    Hi, I need create a reference to one table in other database. I understand that Database Link can be used to connect me to other database but when I am creating the foreing key in my table, I can see only the tables in the schemas that have my data base not the other schemas. I created a connection with database link but I do not see the form to make reference to this connection from the create table wizard. I am using Oracle 9i and the client is 9.01.01.
    Thanks in advance,
    Mónica Alarcón

    We cannot use tables in another table to enforce data integrity. This makes a lot of sense if you think about what would happen if the remote database goes down.
    If you want to do this, then you need to use replication (materilaized view) to bring the parent table's data into the locaL database.
    Cheers, APC

  • Foreign Keys involving two different databases/schemas

    Hi -- I'm wondering if it's possible to set a foreign key that involves tables that live in different databases/schemas. And, if it is possible, is it a horrible design idea?
    Thanks,
    ~Christine

    cav0227, you have asked two different two part questions.
    1 - Is it possible to set up FK that span owners and is this good design?
    Yes, it is possilbe and there if the data is related then yes it is good design. We like to minimize the number of object owners in our system and use a table naming standard where the first two or three letters of the table name represent a system code: ap, ar, gl for accounts receivable, accounts payable, and general ledger. Other may prefer to have an AP owner, AR owner, and a GL owner.
    Ownership has no direct bearing on quality of design. If the tables are related then you should define the FK no matter who the owner is.
    2 - Is it possible to define FK to remote (distributed) tables and is the good design? The answer is no. FK cannot reference remote objects. To enforce referencial integrity accross databases via the database, rather than in the application, requires the use of table triggers.
    As far as good design that depends on why the data is remote and why the tables need to be linked. There are issues related to availability, recovery, and performance when data is distributed. Having such a relationship could be good design or bad design depending on if all the inter-related factors have been considered.
    IMHO -- Mark D Powell --

  • How will get the source code of all the tables in a given schema using SQL?

    Hi All,
    How can we get the source code of all the tables in a given schema using SQL?
    Thanks in Adv.
    Junu

    Try something like...
    set heading off
    set pagesize 0
    col meta_data for a96 word_wrapped
    set long 100000
    SELECT DBMS_METADATA.GET_DDL(object_type, object_name, owner) ||';' AS meta_data
    FROM dba_objects
    WHERE owner = '<SCHEMA NAME>'
      AND object_type not in (<list of stuff you do not want>);                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • To compare Table in different Database

    Hi
    Is possible to compare tables in Different Database ?
    They are same tables , but data can to be different
    TIA

    May be you can try with DBMS_RECTIFIER_DIFF.DIFFERENCES

  • How to create workspace on remote database schema?

    Is it possible to create workspace on remote database schema? I have created a database link on remote database. Now want to create workspace on schema on that remote database. I have seen no option in Apex 4.1. Please have your comments on the topic.
    Regards
    Hasan Al Mamun
    Programmer
    Bangladesh Bank
    Dhaka, Bangladesh

    Hello,
    this forum is dedicated to APEX Listener, a web server alternative for AEPX. I guess you actually wanted to post in {forum:id=137}. I'd recommend to open a new thread there and mark this thread as answered.
    Thanks,
    Udo

  • How to use database link to create table in other database?

    e.g., java jdbc is connected to the database A.
    i want to create one table (Table1)in database B, and then insert data into Table1 select ....from Table2 which is in database A.
    i used the create database link (database name) connect to (database) indentified by .....
    but ...i got the sqlException as i wrote before.
    Thanks again.

    http://forum.java.sun.com/thread.jspa?threadID=656868&messageID=3860293#3860293

  • Tables from 2 different database schemas in 1 module

    I'd like to have only one module to store my source transactional tables.
    In my transactional system, I've got, differente database schemas.
    For example:
    I've got a schema, schema1 with a table called table1 and schema2 with table2.
    I've got a public synonym and granted the privileges to select table2 so, from schema1, I can see table2.
    I'd like to have only one MODULE to store my SOURCE transactional tables.
    But, when I create the module, I have to link it with a specific location, and a location is linked with a specific schema. When the list of objects to load is shown, I see the objects of the schema but no the others pointed with synonyms.
    Example: If I have a location linked to schema1 I only see table1, but don't see table2.
    IS THERE A WAY TO LOAD table1 and table2 IN THE SAME MODULE?
    thanks in advance!

    You cannot access objects in another schema via public synonyms.
    If your location is linked to schema 1, then in schema 1 create a private synonym to schema2.table2, grant read on table2 to schema1 from schema2, and then you will be able to see table2 to import it into OWB if you have the option to included objects referenced by synonyms checked.
    Cheers,
    Mike

  • Can use JDBC to create table in the database?

    other than select, insert, update, delete the record set
    I want to know can I use the JDBE to create table.

    As far as i know you can use 'CREATE TABLE' to create tables.
    Use it in an cn.execute() or cn.executeUpdate().
    I'm not sure about the complete syntax for CREATE TABLE, since you also need to define you fields etc. Try looking on the net for an SQL manual.
    Greetz..

  • How to create a view between two table under different database?

    thx

    Assuming the different database is Oracle, you'll probably need to create a 'dblink'. Researching that topic should get you where you need to go.

  • How can I connect to a different database schema,other than adobe?

    I'm building an application where I want to use a different database for it,for storing additional data for the users(different from "edcprincipaluserentity" table in "adobe" database stores)..How I can connect to my database schema created in MySQL from Workbench,to assign tasks to my users,using the Process Management/Assign Task service?

    You can only assign task to user that are known by the LiveCycle User Manager.
    When you configure LiveCycle, you can tell it where you want to get the users from. They can be created them locally in the local database, or synchronized from an LDAP directory in which case it'll read the users from LDAP and make a copy of some of the properties to the internal LiveCycle database.
    Bottom line, all users have an id (in the edcprincipalentity table) in the adobe database.
    If you need your users to come from a different database, then you need to customize the SPI (security provider interface) so that you can synchronize the users coming from your external database. Again, this is a customization since out of the box, we don't synchronize against external database. But it is possible, the API is there and other customers have done it.
    I hope this clarifies things a bit.
    Jasmin

Maybe you are looking for

  • Grayish stains on wrist rests

    I am wondering if this is just from skin oil or if it is a problem with the material... Right now it is very faint but more visible if I look at it from the side. There are 2 circular grayish blotches in the middle of both wrist rests. The right side

  • How to apply patterns in Java desktop system

    Dear experts, I have developed a System which now only can be use through Browser, in other words,a WEB application for the System has developed which I use MVC pattern in it now,I should develop a client software for some local customers to use syst

  • Developing Help!

    In the video tutorial in iTunes for the introduction to iPhone SDK, it says for my project template to be Cocoa Touch List. I don't have any cocoa touch options displayed on my project templates!

  • Using eval on variables' names

    The line eval("_root."+this.p).display_text.text=this.v works fine, whereas eval("_root."+this.n)=eval("_root."+this.n)+this.step; says "Left side of assignment operator must be variable or property" p is a name of an object created with arrachMovie

  • CRM - Structure

    Hi, Trying to learn CRM - and to start with i have gone through the help.sap.com website to understand the Setting up the Organization structure.... I have refered the information available from the below link: http://help.sap.com/saphelp_crm50/helpd