'Parent' DB Table references 'child' table twice

I'm having fun learning a million new things at once, and I ran into a bit of a wall. I have made the following work using secondary backing beans, but I'm wondering if there isn't a nice simple connection of some sort that would let me avoid the extra code in the future.
So I have a few tables. We will say, table 'employee', 'address' and 'contact_info'.
Employee = {Integer ID,
  String name,
  Integer home_contact_id,
  Integer work_contact_id}
Contact_Info = {Integer ID, Integer address_id, String phone etc}
Address = {Integer ID, String Street, etc}
In the java code, is there a nice fast way to connect the getters of home_contact_id and work_contact_id to Contact_Info objects?
E.g. instead of
public Integer getHome_contact_id(){
return x;
// Something like this
@whichBloodyAnnotation
public WorkContactEntity getWork_contact_id(){
return y;
}I've already figured out the case for the link between the contact_info table and the address table, which is very nice.
Obviously the real world case is different; I would rather live with the extra code in Java than rebuild the data-structure.... On the other hand, if this is considered bad design, I suppose I'd like to know so, and why. I'm not a DB guy, as you may have guessed :~)
Thanks for any help!

I found the solution. Of course, it was incredibly simple.
For those looking, my assumption was that even uni-directional joins required the @annotatoin on both classes (since all the examples show this).
For the code below, you would just do the following:
@OneToOne
@JoinColumn(name = "col_name_in_Address") // 'id' in this case
public Address getHome_contact_id(){return x};
@OneToOne
@JoinColumn(name = "col_name_in_Address") // 'id' in this case
public Address getWork_contact_id(){return y};
No extra code (e.g. annotation) is required in the Address class, beyond that which specifies the columns etc.

Similar Messages

  • Reporting of Child Routed Calls Using Parent TCD table

                       The TCD records of Parent do not show RoutID, ServiceSkillTargetID filed for calls routed by Child ucce. The Calltype ID filed shows "-1" for all such records. The dbo Service Table in parent is correctly populated and contains all child calltypes as peripheral number and mapped to ServiceSkillTargetID.
    But still the TCD records on parent show routeid and serviceskilltargetid as blank for all calls that are routed by Child... any suggestions to fix this.
    My requirement is:- There are around 7 calltypes on child that terminate on a particular skillgroup. I want to report call meterics for any 5 of them and that too by using Parent system and not Child. I am not able to differentiate the calls as serviceskilltargetid field or routeid field is not populated.

    Hi Navjit,
    Is it a typical Parent-Child Call Flow ?
    Are you open to saving some information in call peripheral variable which can help in corelating call between parent & child ?

  • Cost of using subquery vs using same table twice in query

    Hi all,
    In a current project, I was asked by my supervisor what is the cost difference between the following two methods. First method is using a subquery to get the name field from table2. A subquery is needed because it requires the field sa_id from table1. The second method is using table2 again under a different alias to obtain table2.name. The two table2 are not self-joined. The outcome of these two queries are the same.
    Using subquery:
    select a.sa_id R1, b.other_field R2,
    (select b.name from b
    where b.b_id = a.sa_id) R3
    from table1 a, table2 b
    where ...Using same table twice (table2 under 2 different aliases)
    select a.sa_id R1, b.other_field R2, c.name R3
    from table1 a, table2 b, table2 c
    where
    c.b_id = a.sa_id,
    and ....Can anyone tell me which version is better and why? (or under what circumstances, which version is better). And what are the costs involved? Many thanks.

    pl/sql novice wrote:
    Hi all,
    In a current project, I was asked by my supervisor what is the cost difference between the following two methods. First method is using a subquery to get the name field from table2. A subquery is needed because it requires the field sa_id from table1. The second method is using table2 again under a different alias to obtain table2.name. The two table2 are not self-joined. The outcome of these two queries are the same.
    Using subquery:
    Using same table twice (table2 under 2 different aliases)
    Can anyone tell me which version is better and why? (or under what circumstances, which version is better). And what are the costs involved? Many thanks.In theory, if you use the scalar "subquery" approach, the correlated subquery needs to be executed for each row of your result set. Depending on how efficient the subquery is performed this could require significant resources, since you have that recursive SQL that needs to be executed for each row.
    The "join" approach needs to read the table only twice, may be it can even use an indexed access path. So in theory the join approach should perform better in most cases.
    Now the Oracle runtime engine (since Version 8) introduces a feature called "filter optimization" that also applies to correlated scalar subqueries. Basically it works like an in-memory hash table that caches the (hashed) input values to the (deterministic) correlated subquery and the corresponding output values. The number of entries of the hash table is fixed until 9i (256 entries) whereas in 10g it is controlled by a internal parameter that determines the size of the table (and therefore can hold different number of entries depending on the size of each element).
    If the input value of the next row corresponds to the input value of the previous row then this optimization returns immediately the corresponding output value without any further action. If the input value can be found in the hash table, the corresponding output value is returned, otherwise execute the query and keep the result combination and eventually attempt to store this new combination in the hash table, but if a hash collision occurs the combination will be discarded.
    So the effectiveness of this clever optimization largely depends on three different factors: The order of the input values (because as long as the input value doesn't change the corresponding output value will be returned immediately without any further action required), the number of distinct input values and finally the rate of hash collisions that might occur when attempting to store a combination in the in-memory hash table.
    In summary unfortunately you can't really tell how good this optimization is going to work at runtime and therefore can't be properly reflected in the execution plan.
    You need to test both approaches individually because in the optimal case the optimization of the scalar subquery will be superior to the join approach, but it could also well be the other around, depending on the factors mentioned.
    Regards,
    Randolf
    Oracle related stuff blog:
    http://oracle-randolf.blogspot.com/
    SQLTools++ for Oracle (Open source Oracle GUI for Windows):
    http://www.sqltools-plusplus.org:7676/
    http://sourceforge.net/projects/sqlt-pp/

  • ORA 2266 -- Drop parent partition with no child records exists

    Hi Team ,
    Here I have a parent partitioned table and child refrenced non-partition table .
    To drop parent partition I am doing
    1)delete from child
    2)delete from parent partition
    3)alter table drop parent partition
    ---and its working fine .
    I am trying to do below which is not working , Could you please guide me why it is not
    1)delete from child
    2)alter table drop parent partition -- throwing below error
    Summarizing ,
    Why I am not able to drop/trunc a parent partition(no corresponding rows exists in child tables) where as able to do after deleting the rows from parent partition .
    From Doc :
    Error: ORA 2266
    Text: table has some unique/primary keys that are referenced by some foreign k
    eys
    Cause: Attempt to drop the table while the table still has some unique/
    primary keys that are referenced by some foreign keys.
    Action: Remove all such references to the keys before dropping the table
    Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64bit Production
    PL/SQL Release 11.2.0.2.0 - Production
    CORE     11.2.0.2.0     Production
    TNS for Linux: Version 11.2.0.2.0 - Production
    NLSRTL Version 11.2.0.2.0 - Production

    Oracle decides what the rules are & you must conform to them
    bcm@bcm-laptop:~$ oerr ora 2266
    02266, 00000, "unique/primary keys in table referenced by enabled foreign keys"
    // *Cause: An attempt was made to truncate a table with unique or
    //         primary keys referenced by foreign keys enabled in another table.
    //         Other operations not allowed are dropping/truncating a partition of a
    //         partitioned table or an ALTER TABLE EXCHANGE PARTITION.
    // *Action: Before performing the above operations the table, disable the
    //          foreign key constraints in other tables. You can see what
    //          constraints are referencing a table by issuing the following
    //          command:
    //          SELECT * FROM USER_CONSTRAINTS WHERE TABLE_NAME = "tabnam";

  • Fastest way to find parents with only one child?

    I have two very large tables (both >6 million rows) in an oracle 8i DB. They have a parent child relationship and I would like to construct a query to give me the parents that have only one child......syntactically, what's the best way to construct this query?
    I was going to try:
    select join_id
    FROM parent
    where join_id in (select join_id, count(join_id)
    FROM child
    group by join_id
    having count(*)=1)
    but then I realized that the subselect has two columns to return and the primary query is only expecting one column, so this will not work.
    I suspect there's a quick and dirty way to find out what parents have only one child....
    I thought of using rowid's but am not sure this is the best way and in the example below I tried, I'm having problems b/c of functions not being allowed in the where clause.....
    select join_id
    from child d
    where rowid in (select min(rowid)
              FROM child s
              WHERE min(d.rowid)=max(s.rowid)
              AND s.join_id=d.join_id))
    Any thoughts?

    The two tables are order_header and order_detail. The order_header carries order specific information and the detail contains item specific information.
    So if you had ordered three separate products, you would have:
    one row in the order_header table (parent)
    and three rows in the order_detail table (child)
    They are linked by order_number.
    I presented the problem this way to make it more accessible to more posters.....;)
    One possible solution that I've thought of for my problem is this:
    select join_id
    from child_table d
    where (d.rowid, d.rowid) IN (select min(rowid) MIN_ROW
                   ,max(rowid) MAX_ROW
                   FROM child_table
                   WHERE s.str_order_number=d.str_order_number
                   AND s.date>='30-JAN-2005'
                   AND s.date<='31-JAN-2005'))
    I think this might work because I think that we can safely assume that if the minimum rowid and the maximum rowid (with the same join_id ) are the same then there is only one child record.....is this logic correct?

  • Is it possible to put two different colors in tree parent node background and child nodes background?

    Is it possible to put two different colors in tree parent
    node background and child nodes background?
    Any help will be very helpful.
    Thanks

    Hi PanosE,
    Yes, you can set up another Standard Edition Server in child domain and then deploy pool pairing.
    You need to deploy a new Front End Pool for the new Standard Edition Server.
    A similar case for your reference.
    https://social.technet.microsoft.com/Forums/office/en-US/eca4299c-8edb-481e-b328-c7deba2a79ba/lync-2013-standard-edition-lync-fe-pools-in-multiple-domain-single-forest-senario?forum=lyncdeploy
    Best regards,
    Eric
    Please remember to mark the replies as answers if they help, and unmark the answers if they provide no help. If you have feedback for TechNet Support, contact [email protected]

  • How to get the parent window in sub-child controller class in javafx?

    how to get the parent window in sub-child controller class in javafx?

    You can get the window in which a node is contained with
    Window window = node.getScene().getWindow();Depending when this is invoked, you might want to check the Scene is not null before calling getWindow().
    If the window is a stage that is owned by another window, you can get the "parent" or "owner" window with
    Window owner = null ;
    if (window instanceof Stage) {
      Stage stage = (Stage) window ;
      owner = stage.getOwner();
    }

  • Is it possible to call a function in a parent component from a child component in Flex 3?

    This is probably a very basic question but have been wondering this for a while.
    I need to call a function located in a parent component and make the call from its child component in Flex 3. Is there a way to access functions in a parent component from the child component? I know I can dispatch an event in the child and add a listener in the parent to call the function, but just wanted to know if could also directly call a parent function from a child (similar to how you can call a function in the main mxml file using Application.application). Thanks

    There are no performance issues, but it is ok if you are using the child component in only one class. Suppose if you want to use the same component as a child to some bunch of parents then i would do like the following
    public interface IParentImplementation{
         function callParentMethod();
    and the parent class should implement this 'IParentImplementation'
    usually like the following line
    public class parentClass extends Canvas implements IParentImplementation{
              public function callParentMethod():void{
         //code
    in the child  you should do something like this.
    (this.parent as IParentImplementation).callParentMethod();
    Here using the Interfaces, we re decoupling the parent and the child
    If this post answers your question or helps, please mark it as such.

  • Calling a Function in the Parent Window from the Child Window

    QUESTION: How do I call a function resident in the parent
    window from a child window?
    BACKGROUND
    I have a JavaScript function resident in the parent window
    that reformats information obtained from the Date object and writes
    the result to the parent window using the document.write( ) method.
    I would like to call this function from the child window and have
    it write to the child window instead. Is this possible? If not,
    must I rewrite the entire function and nest it in the below code?
    If so, what is the proper form of nesting?
    CODE: The code that creates and fills the child window is
    provided below. The highlighted area indicates where I would like
    to enter the information from the function resident in the parent
    window. I have tried every imaginable permutation of code that I
    can imagine and nearly destroyed my parent document in the process.
    I am very happy that I had a back-up copy!
    function openCitationWindow() {
    ciDow = window.open("", "", "width=450, height=175, top=300,
    left=300");
    ciDow.document.write("A proper way to cite a passage of text
    on this page:<br /><br />Stegemann, R. A. 2000.
    <cite>Imagine: Bridging a Historical Gap</cite>. " +
    document.title + ". [<a href='" + location.href + "'
    target='_blank'>online book</a>] &lt;" + location.href
    + "&gt; (");
    MISSING CODE;
    ciDow.document.write(").<br /><br /><input
    type='button' value='Close Window' onclick='window.close()'>");
    ciDow.focus();

    Never mind - I was doing something very stupid and wasn't
    calling the function as a method of a movie clip. I was simply
    calling checkTarget(event) rather than
    event.currentTarget.checkTarget(event); which seems to work.

  • Get parent databank in a child scipt

    Hi All,
    Is there any method to get parent databank in a child script. Currently I'm using variables to pass data from parent script to child script.
    Appreciate if anyone helps me to solve this scenario.
    Regards,
    Deepu M

    Hi,
    Solved.
    If alias name of parent databank always remains same, then you can directly use +"{{db.aliasName.ColumnName}}"+
    Otherwise, to get parent databank alias name use
    ScriptPackage parentScript= utilities.getCurrentVUSer().getParentUser().scriptPackage;
              ArrayList<String> parentDB = parentScript.getDatabankAliases();
    +info(eval("{{db."+ parentDB.get(0) + ".ColumnHeader}}"));+
    Regards,
    *Deepu M*

  • We need to pass the customer id from Parent BO report  to Child BO report.

    Hello Experts
    We are using SAP BI BO 4.1 for Business Objects  and SAP BW 7.3 as BW Backend.
    Requirement: We need to pass the customer id from Parent BO report  to Child BO report.
    Issue: Customer (0CUST_SALES__CUSTOMER) Characterisitic is used where in the display characteristic is set to Key i.e 'Display As "Key" ' But the In BO the Dimension appreas as Text .
    I have tried out by changing the display characteristic as KEY/ TEXT/ KEY & TEXT but still at the BO end the it is displayed as TEXT.
    Workaround Tried:  I have used the detailed object for the Dimension 0CUST_SALES__CUSTOMER- key in SAP BO i.e the key value where in we are able to view the customer ID. But we are unable to pass the value from parent report to child report  as the query level Filter cannot be applied onto a detaield object.
    Is this a BI- BO Integration issue?? Kindly help me out with the same.
    Regards
    Akshay.

    Hello Victor,
    I have gone through the doc sent. It was helpful.
    Info Object (BW)/ Dimension (BO): 0CUST_SALES__CUSTOMER.
    In SAP BO the dimension has detailed object under it 0CUST_SALES__CUSTOMER- KEY and 0CUST_SALES__CUSTOMER- TEXT.
    Now I can pass "0CUST_SALES__CUSTOMER- KEY" from the parent report. But in the child report we cannot apply Query level Prompt / Filter on the detailed object which will hold the parameter passed from the Parent report.
    Q1: Can we apply prompts on a detailed objects?? Is there any configuration  changes required.
    Q2: Is there any other method the achive the same??
    Regards
    Akshay.

  • How to Get the Parent Process ID from Child BPEL Process

    Hi All,
    We have a requirement to get the Parent BPEL Process ID from Child BPEL Process. One way is we can pass the Parent BPEL process ID from Parent BPEL Process to Child BPEL process. Is there any standard function available to get the Parent BPEL process ID from Child Process?
    P.S: We are using BPEL 10.1.3 Version.
    Please share any info on this.
    Thanks in Advance,
    Saravana

    Hi Saravana,
    The existing methods in 10.1.3x allow a following (a bit of a convoluted way):
    In a BPEL Java embedding activity, you can use the following code to get the parentProcessname:
    String parentInstanceId = getParentId();
    String parentProcessname = getLocator().locator.lookupInstance(parentInstanceId).getProcess().getProcessId().getProcessId();Hope this helps,
    Regards,
    Shanmu
    http://www.prshanmu.com/articles/

  • Function module to assign a parent role to a child role

    Hi All,
    Is there any function module that can be used to assign a parent role to a child role.
    I have tried to debug the PFCG transaciton but was not successful in find one.
    Please help me out.
    Thanks,
    Hari.

    Hello Hari
    It would be more logic to create a child role from a parent role yet there may be demands for the other way around. I would like to add that you assign not just a but the parent role since a child role can have only a single parent role.
    The parent role is defined by AGR_DEFINE-PARENT_AGR. Thus, you could try to use the following function modules:
    PRGN_STRU_LOAD_DEFINITION
    PRGN_STRU_SAVE_DEFINITION
    Obviously there are additional steps required in order to create a fully functional child role.
    Regards,
      Uwe

  • Delete parent without entries in child table

    Hi
    I have two table with millions of records. The child table has referential integrity with the parent and the foreign-key is indexed.
    I must delete all the parent rows with no corresponding entries in child table.
    What is the faster way?

    You might test using DML error logging so you don't have to 'find' the rows. Just delete them all and let Oracle put the error rows in the log table.
    Try this using the sample DDL you provided above:
    exec DBMS_ERRLOG.CREATE_ERROR_LOG ('CHILD')
    ALTER TABLE ERR$_CHILD DROP COLUMN C_ID;
    ALTER TABLE ERR$_CHILD DROP COLUMN C_P_ID;
    delete from parent
    LOG ERRORS INTO err$_child ('DELETE') REJECT LIMIT UNLIMITED;
    The drawback is the space taken for the required columns in the log table for child row data that had a parent. The two ALTER statements above DROP the actual 'child' columns from the log table after it is created to save space but the required fields will still be populated.
    The DELETE will be successful and will remove 'parent' rows with NO children.

  • Use same table twice in subform

    Hi,
    i´ve created a form like this
    subformA   -> positioned
    --subformB -> flowed
    table
    header
    body row
    Everything is working fine and a I´m able to see the expected data.
    But when my table includes more than 10 rows it destroys the layout of my page.
    My idea:
    Create a second subform with same table data and place it right beside it. And using FormCalc to show data from row 11 to end.
    But only the first subform is filled. There is no data in second subform (FormCalc code is not implemented).
    It seems, that I can´t use same tabele twice.
    Any ideas?
    Regards
    Andy

    Hi Andy,
    Have both the subforms as flowed and page breaked, it should work.
    As per as having 2 tables techically i believe its not possible.reason behind.
    When you do data binding for 1st table and say multiple rows, at runtime data is iterated and displayed in the 1st table.
    when it reaches to the 2nd table the pointer on the table data source is already eof i.e., last record so it will not display it again.
    to acheive this on form load of the 2nd table you need to initialize and iterate through the data source again.
    I have never tested this scenario but read it in some adobe fourms.
    Check it and let me know, if its still not working i can design a sample form with this scenario for you.
    Cheers,
    Sai

Maybe you are looking for

  • Automate a BI report to flat file on to a FTP server.

    Hello all, I have an same issue like the following thread. After extract CSV file successfully to the directory, but unable to find the file. Any thought? Automate a BI report to flat file on to a FTP server. Regards!

  • To develop Z-Report related to Cost Analysis as in COR3

    Hi, I am trying to develop a Z-Report similar to Cost analysis as in COR3, I just want to know the tables where actually the Planned Qty,Planned Cost,Actual Qty,Actual Cost are getting stored.My requirement is to run it for Multiple Orders with some

  • Unit Test code using wrong persistence unit

    In the midst of learning Maven, I created a simple application in which I am using JPA (Java Persistence 1.0.2) with EclipseLink implementation (2.0.2). Note: This is an Application Managed environment. So I manually control EntityManager's life cycl

  • Capturing Movies on the iMac

    I am a new Mac user having used the PC for many years. I have many VCR and other Hi8 tapes of home movies I would like to get into my iMac for editing and storage. I have an external drive that connects to my firewire port, but am looking for the bes

  • Help! how can i retrieve / restore my songs!!!

    itunes deleted all my stored music on my ipod classic coz i forgot to tick manually manage music. can i still restore all the music i had before an all the folders as well??? please help!