Need to be enlightened on Parent, Child object assignments
Hi!
I am too boggled with parent class, child class objects assignments. For example say I have something like this:
class parent{
int a;
void doStuff(){...}
class child extends parent{
int b;
void doOtherStuff(){...}
}Ok. Now. if have have something like this:
parent p;
child c;Then which one of the below is legal and why and why not?
1.) c = p;
2.) p = c;
I think p = c is legal. If so, can I do p.a =12; p.b=15;
Why and why not?
Please be my lifesaver.
Thank You for reading!
parent p;
child c;
If these are defined as global variables then both p and c will be null, meaning they refer nothing. Since a child inherits properties of the parent you can hold a child object using a parent reference
so this is legal
p = c;
(Note: you need to understand the concept of a reference and object well. Here p and c are both references not objects).
When you hold a child object using a parent's reference only parent's properties are visible. If you want to see the child's properties then you need to cast that reference to a child reference. So you can't say p.b=12.
Hope you got what you want
Similar Messages
-
Help needed on Many to Many Parent Child Relationship (PL/SQL)
Friends,
Please help me.
I have table where in two columns are having many to many parent child relation ship. It means child can have multiple parents.
Table strucuture and sample records given below. Here 334059 is GRAND PARENT of all child records.
PARENT CHILD LEVEL Usage
334059 380499 1 This Level has 2 childs
334059 334730 1
334730 335629 2 This level too has 2 childs where in 380499 is child of 334730 & 334059 also.
334730 380499 2
380499 380497 2 This level has 3 childs and 88888 is having further child.
380499 334730 2
380499 88888 2
88888 99999 3 It has one child 99999 and has further child 10101.
99999 10101 4 It has one child 10101 and has further child 11111.
10101 11111 5 It has one child 11111 and has no further child. I.e leaf node.
11111 0 6 leaf node
What I want is records in same level above. I am using below code but its implementing only UPTO 2nd LEVEL given above.
Further its not going i.e 3,4,5,6 level. Could you please help me?
DECLARE
CURSOR main_pc(p_child pc.child%type) IS
SELECT CHILD
FROM pc where parent = p_child;
CURSOR main_dw(p_child dw_exrdbo.exr_parent_child.child_fund%type,
p_level NUMBER) IS
SELECT DISTINCT CHILD_FUND,LEVEL_NUMBER FROM dw_exrdbo.exr_parent_child
where parent_fund = p_child
and parent_fund <> child_fund
and level_number = p_level;
v_next_parent pc.child%type;
v_level NUMBER := 1;
v_grand_parent dw_exrdbo.exr_parent_child.parent_fund%type := 334059;
v_parent dw_exrdbo.exr_parent_child.parent_fund%type;
vDone BOOLEAN;
v_xyz dw_exrdbo.exr_parent_child.parent_fund%type;
v_cnt NUMBER := 0;
BEGIN
DELETE FROM dw_exrdbo.exr_parent_child;
COMMIT;
INSERT INTO dw_exrdbo.exr_parent_child
SELECT PARENT, CHILD, 'INVONE', 12345, 'P',0,1
FROM pc where parent = v_grand_parent
AND NOT EXISTS (select 'x' from dw_exrdbo.exr_parent_child where parent_fund = v_grand_parent);
COMMIT;
FOR i IN (select distinct child FROM pc WHERE parent = v_grand_parent) --334059
LOOP
DBMS_OUTPUT.PUT_LINE('Next Parent is '||v_parent);
FOR x IN main_pc(i.child)
LOOP
INSERT INTO dw_exrdbo.exr_parent_child
(parent_fund, child_fund, source_application, valuation_date_sid, parent_child_flag, child_count, level_number)
VALUES(i.child, X.CHILD, 'INVONE', 12345, 'C',0,1+1);
COMMIT;
END LOOP;
END LOOP;
END;
Thanks in advance!!!
Regards,
JiggerHi, Jigger,
Sorry, I can't tell what you want.
Whenever you have a question, please post CREATE TABLE and INSERT statements for your sample data, and the results you want from that data.
Explain, using specific examples, how you get those results from that data.
Always say what version of Oracle you're using. -
Add/remove parent, child objects. help needed
I'm working on interactive map for my client. But i'm stuck on functionality.
It's basically has 3 locations (child1-3) on base map(Bg), each stands for link to their assigned popup boxes.
Child2 and Child3 shares same Mag object which shows additional 5 locations.
i've done showing my base Bg and 3 initial locations. Also i tried to show first popup box by clicking child1 and it has some success.
But further i'm having problem for removing Box1 and it's BoxX button which means i want to return my Main_MC state by removing objects.
**pls help me on my work so i'll appreciate for your valuable time for helping me. I'm open to send some bonus via Skrill or Paypal.
Main_MC (parent)+
|
|___Bg
|
|
|___child1+
| |___ Box1
|
|___child2+
| |
| | |__box2
| | |__box3
| |___Mag+___|__box4
| | |__box5
| | |__box6
| |
| |
| |
|___child3+
Here is my toddler looking code i just started.
package{
import flash.display.Sprite;
import flash.display.DisplayObject;
import flash.events.MouseEvent;
import flash.net.URLRequest;
import flash.events.Event;
public class Main extends Sprite{
private var Bg:Sprite;
private var child1:Sprite;
private var child2:Sprite;
private var child3:Sprite;
public function Main(){
var Bg:Sprite = new BgInstance();
Bg.x=360;
Bg.y=212;
Bg.name="BgMap"
addChild(Bg);
child1 = new child1Instance();
child1.buttonMode = true;
child1.x=479;
child1.y=132;
child1.name="child1Name";
child1.addEventListener(MouseEvent.CLICK, showBox);
addChild(child1);
child2 = new child2Instance();
child2.buttonMode = true;
child2.x=463;
child2.y=282;
child2.name="child2Name";
child2.addEventListener(MouseEvent.CLICK, showMag);
addChild(child2);
child3 = new child3Instance();
child3.buttonMode = true;
child3.x=389;
child3.y=335;
child3.name="child3Name";
addChild(child3);
} //closing brace for Function Main
//Handler
private function showBox (e:MouseEvent):void{
var box1:Sprite;
box1=new box1Instance();
box1.x=-279;
box1.y=-32;
box1.name = "box1name";
var boxX:Sprite;
boxX=new boxXInstance();
boxX.x=-159;
boxX.y=-79;
boxX.name="boxXname";
buttonMode = true;
child1.addChild(box1);
child1.addChild(boxX);
trace(child1.numChildren); //it returns 3 instead of 2 ?
trace(box1.numChildren); //it returns 3 instead of 0 ?
boxX.addEventListener(MouseEvent.CLICK, boxXHandler);
} //closing brace for function showBox
//function for removing showBox
private function boxXHandler(evt:MouseEvent):void {
child1.removeChildAt(0); // it removes child1 itself on first click?
}//closing brace for function boxXHandler
//function for managing showMag
private function showMag (e:MouseEvent):void{
var MagBox:Sprite;
MagBox=new MagInstance();
MagBox.x=-275;
MagBox.y=-95;
MagBox.name="MagBoxName";
var MagBoxX:Sprite;
MagBoxX=new magXInstance();
buttonMode = true;
MagBoxX.x=-145;
MagBoxX.y=-190;
MagBoxX.name="MagBoxXName";
child2.addChild(MagBox);
child2.addChild(MagBoxX);
trace(child2.getChildAt(0).name);
MagBoxX.addEventListener(MouseEvent.CLICK, MagBoxXHandler);
} //closing brace for function showMag
private function MagBoxXHandler(evt:MouseEvent):void {
} //closing brace for Class Main
} //closing brace for packageThis is my code for right now:
package{
import flash.display.Sprite;
import flash.display.DisplayObject;
import flash.events.MouseEvent;
import flash.net.URLRequest;
import flash.events.Event;
import flash.events.EventDispatcher;
public class Main extends Sprite{
private var Bg:Sprite;
private var child1:Sprite;
private var child2:Sprite;
private var child3:Sprite;
public function Main(){
var Bg:Sprite = new BgInstance();
Bg.x=360;
Bg.y=212;
Bg.name="BgMap"
addChild(Bg);
child1 = new child1Instance();
child1.buttonMode = true;
child1.x=479;
child1.y=132;
child1.name="child1Name";
child1.addEventListener(MouseEvent.CLICK, showBox);
addChild(child1);
child2 = new child2Instance();
child2.buttonMode = true;
child2.x=463;
child2.y=282;
child2.name="child2Name";
child2.addEventListener(MouseEvent.CLICK, showMag);
addChild(child2);
child3 = new child3Instance();
child3.buttonMode = true;
child3.x=389;
child3.y=335;
child3.name="child3Name";
addChild(child3);
} //closing brace for Function Main
//Handler
private function showBox (e:MouseEvent):void{
var box1:Sprite;
box1=new box1Instance();
box1.x=-279;
box1.y=-32;
box1.name = "box1name";
var boxX:Sprite;
boxX=new boxXInstance();
boxX.x=-159;
boxX.y=-79;
boxX.name="boxXname";
buttonMode = true;
child1.addChild(box1);
child1.addChild(boxX);
child1.removeEventListener(MouseEvent.CLICK, showBox);
//tired to remove event listerner for child1 ?
boxX.addEventListener(MouseEvent.CLICK, boxXHandler);
} //closing brace for function showBox
//function for removing showBox
function boxXHandler(evt:MouseEvent){
child1.removeChild(child1.getChildByName("box1name"));
child1.removeChild(child1.getChildByName("boxXname"));
child1.addEventListener(MouseEvent.CLICK, showBox);
// tried to reassign event listener for child1 ?
}//closing brace for function boxXHandler
//function for managing showMag
private function showMag (e:MouseEvent):void{
var MagBox:Sprite;
MagBox=new MagInstance();
MagBox.x=-275;
MagBox.y=-95;
MagBox.name="MagBoxName";
var MagBoxX:Sprite;
MagBoxX=new magXInstance();
buttonMode = true;
MagBoxX.x=-145;
MagBoxX.y=-190;
MagBoxX.name="MagBoxXName";
child2.addChild(MagBox);
child2.addChild(MagBoxX);
child2.removeEventListener(MouseEvent.CLICK, showMag);
trace(child2.getChildAt(0).name);
MagBoxX.addEventListener(MouseEvent.CLICK, MagBoxXHandler);
} //closing brace for function showMag
function MagBoxXHandler(evt:MouseEvent):void {
child2.removeChild(child2.getChildByName("MagBoxName"));
child2.removeChild(child2.getChildByName("MagBoxXName"));
child2.addEventListener(MouseEvent.CLICK, showMag);
} //closing brace for Class Main
} //closing brace for package -
Sorting a list with parent/child object relations
Hi,
I have an ArrayList of Genre objects that I want to sort:
class Genre{
int CategoryID;
int ParentCategoryID;
String name;
String level;
Example objects:
Pop (CategoryID=10, ParentCategoryID=root, "popular music", 1);
Jazz (CategoryID=11, ParentCategoryID=root, "jazz music", 1);
Indie pop (CategoryID=12, ParentCategoryID=10, "indie pop", 2);
American Indie pop (CategoryID=13, ParentCategoryID=12, "american indie pop", 3);
Soul (CategoryID=15, ParentCategoryID=root, "soul music", 1);
Commercial pop (CategoryID=14, ParentCategoryID=10, "commercial pop", 2);
I hope that you see the point:
I want that the order will be like this in my arraylist:
jazz music
popular music
commercial pop
indie pop music
american indie pop
soul music
I'll implement the comparator-class in Genre and then add the compareTo-method in my genre-class.
But my brain is too tired to figure out what to write in the compareTo-method?
Have somebody done a similar method??
Best regards,
ThomasUnfortunately is this solution not plausible since I
don't can have the parent genre in the genre class.
... Hashmap?Hashmap works. Here you go, using your structure, minus the level, I'm sure you can work around that though. Don't use -1 as a category id, it's reserved for your root. This code is not thread safe, I leave that to you. Don't forget that as implemented, parent Genres must be constructed prior to any of their children. You could get around this with a two pass initialization process.
// Not thread safe.
import java.util.*;
public class Genre implements Comparable {
private static Map<Integer, Genre> genreForId = new HashMap<Integer, Genre>();
private int id;
private int level;
private int parentId;
private String name;
public Genre(int id, int parentId, String name) {
this.id = id;
this.parentId = parentId;
this.name = name;
this.level = level(this);
Genre.genreForId.put(id, this);
private static int level(Genre genre) {
int i = 0;
while (genre != null) {
genre = genre.getParent();
i++;
return i;
public static void main(String[] args) {
Genre pop = new Genre(10, -1, "popular music");
Genre jazz = new Genre(11, -1, "jazz music");
Genre indiePop = new Genre(12, 10, "indie pop");
Genre americanIndiePop = new Genre(13, 12, "american indie pop");
Genre soul = new Genre(15, -1, "soul music");
Genre commercialPop = new Genre(14, 10, "commercial pop");
Genre[] genres = { pop, jazz, indiePop, americanIndiePop, soul,
commercialPop };
Arrays.sort(genres);
System.out.println(Arrays.toString(genres));
public int compareTo(Object o) {
Genre lhs = this;
Genre rhs = (Genre) o;
switch (Integer.signum(lhs.getLevel() - rhs.getLevel())) {
case -1:
rhs = rhs.getParent();
if (lhs == rhs)
return -1;
break;
case 0:
if (lhs == rhs)
return 0;
else {
if (lhs.getParent() == rhs.getParent())
return lhs.getName().compareTo(rhs.getName());
else {
lhs = lhs.getParent();
rhs = rhs.getParent();
break;
case 1:
lhs = lhs.getParent();
if (lhs == rhs)
return 1;
return lhs.compareTo(rhs);
public int getLevel() {
return level;
public String getName() {
return name;
public Genre getParent() {
return Genre.genreForId.get(getParentId());
public int getParentId() {
return parentId;
public String toString() {
return name;
}-S -
Parent/Child Master Data Type
I recently created a new master data type in my model, which included one attribute with the 'parent' check box checked - to signify that it was to be used as the parent.
Upon activating the master data type - the system auto generated several other attributes within the master data type. My question is, what is the purpose of these additional attributes and how are they to be used?
Before Activation:
Attribute
Description
Notes
ID
ID
<< marked as key and as required
DESCR
Description
<< no special check boxes checked
PID
Parent ID
<< marked with parent check box
After activation:
Attribute
Description
Notes
ID
ID
<< marked as key and as required
DESCR
Description
<< no special check boxes checked
PID
Parent ID
<< marked with parent check box
IDA
Ancestor: ID
<< auto added after activation
IDL
Level: ID
<< auto added after activation
IDLA
Ancestor: Level: ID
<< auto added after activation
IDPTH
Path: ID
<< auto added after activation
IDPTHA
Ancestor: Path: ID
<< auto added after activation
DEACRA
Ancestor: Description
<< auto added after activation
PIDA
Ancestor: Parent ID
<< auto added after activationhttps://share.sap.com/a:r2l29c/MyAttachments/38b00c31-a7f4-404c-8247-1a99ef4b0509/
Hey JJ,
The purpose of these attributes is for parent-child hierachy relationship.
In addition to above mentioned attributes, you should also notice (via HANA studio), that another Planning object gets generated automatically. The new planning object should be the name of your parent-child object plus "_ANC" prefix at the end.
If you take a look at this planning object, you will notice that the object contains all the generated attributes (your attriubute plus "A" prefix at the end) in the definition.
Once you load data into your parent-child hiearchy object the "_ANC" object will automatically get populated with parent-child node relationship.
"A-prefix" attriubutes essentially represents the attributes of ancestor in this case.
In addition, in order to do Ancestor rolllup in your calculation you will also need to create an ancestor planning level which contains all the attriubutes of your base planning level as well as these "A-Prefix" attributes.
Please take a look at the document we created for "How to configure Parent-Child Hiearchy" from the share link
It has more detailed information.
Thanks.
Daniel. -
Problem creating non-persistent Child Objects
I have the need to create a non persistable child object in the
jdoPreStore of a parent object. I then perform some tests on the parent
to determine if the child object needs to be persisted or not. If I leave
the child non persistent it still writes to the database.
I was performing the follwoing piece of code
Class Parent {
// The relationship is a 0 to many
public Child createChild() {
Child child = .....//create non persistent object
child.setParent(this);
getChild().add(child);
It appears that if I remove the getChild().add(child). It does not
persist (as desired).
Is this correct behaviour?? I dont think that it should be, but if it is
then I have a further problem.
If that child object inherits from another object and you remove the
getChild().add(child) kodo outputs an invalid object to the database. It
doesnt insert a row to the child table. But it inserts a row to the
childs inherited object table. This is now an invalid object and will
fail upon loading.
Any help on this would be appreciated.
Thanks
Luke.JDO has something called persistence by reachability. This means that
objects do not have to explicitly be marked as to be persistent as JDO
will traverse the object graph to ensure that all nodes are persistent.
I think you are seeing this behavior combined with another side
behavior: Kodo requires that both sides of a relation be set.
Basically, keep your objects in synch (set both sides of the relation).
And if you want to hold onto a reference to non-persistent object
before you decide what to do with it, add a transient field or a field
marked "persistence-modifier="none"" in your metadata and then process
those transient fields in jdoPreStore ().
i.e.
if (//businessLogic is true)
persistentField = transientField;
Luke wrote:
I have the need to create a non persistable child object in the
jdoPreStore of a parent object. I then perform some tests on the parent
to determine if the child object needs to be persisted or not. If I leave
the child non persistent it still writes to the database.
I was performing the follwoing piece of code
Class Parent {
// The relationship is a 0 to many
public Child createChild() {
Child child = .....//create non persistent object
child.setParent(this);
getChild().add(child);
It appears that if I remove the getChild().add(child). It does not
persist (as desired).
Is this correct behaviour?? I dont think that it should be, but if it is
then I have a further problem.
If that child object inherits from another object and you remove the
getChild().add(child) kodo outputs an invalid object to the database. It
doesnt insert a row to the child table. But it inserts a row to the
childs inherited object table. This is now an invalid object and will
fail upon loading.
Any help on this would be appreciated.
Thanks
Luke.
Steve Kim
[email protected]
SolarMetric Inc.
http://www.solarmetric.com -
Determining Parent/Child Relationships of Sets
Is there an SAP function module or set of tables that will provide parent/child relationships of a set? For example lets say I have a set that looks like:
TOPNODE
...SUBNODE1
......SUBNODE1A
...SUBNODE2
I need something that shows me
PARENT CHILD
TOPNODE SUBNODE1
SUBNODE1 SUBNODE1A
TOPNODE SUBNODE2
I found a FM called G_SET_TREE_IMPORT but I don't see any parent/child relationships there.Hi Wardell,
Use Class : <b>cl_gui_column_tree</b>
data : column_tree TYPE REF TO cl_gui_column_tree,
CREATE OBJECT column_tree
EXPORTING
parent =
split_container->top_left_container
node_selection_mode =
cl_gui_column_tree=>node_sel_mode_single
item_selection = 'X'
hierarchy_column_name = 'COLUMN1'
hierarchy_header = hhdr
EXCEPTIONS
lifetime_error = 1
cntl_system_error = 2
create_error = 3
illegal_node_selection_mode = 4
failed = 5
illegal_column_name = 6
OTHERS = 7
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
Reward points if helpful. -
Parent Child hierarchy Scenario
Hi friends,
Im just working on the parent child hierarchy using the following link with the sample data.
http://www.oracle.com/webfolder/technetwork/tutorials/obe/fmw/bi/bi11115/biadmin11g_02/biadmin11g.htm_
I tried to implement the same hierarchy using my local data instead of referring to the sample data.
I have a below query which returns the employee with manager along with the employee position
select distinct papf.person_id, papf.full_name "Employee Name", supf.person_id "Manager Id", supf.full_name "Manager Name", pj.name "Position Name"
from per_all_people_f papf, per_all_assignments_f paaf, per_all_people_f supf, per_jobs pj
where papf.person_id = paaf.person_id and supf.person_id = paaf.supervisor_id and paaf.job_id = pj.job_id
and trunc(sysdate) between paaf.effective_start_date and paaf.effective_end_date and
trunc(sysdate) between papf.effective_start_date and papf.effective_end_date
Im looking forward to implement the same result in my BI with a parent-child hierarchy.
Since i have imported three tables to my physical layer
per_all_people_f------------Dimension
per_all_assignments_f-----Fact
per_jobs---------------------DimensionFor creating parent-child in BI, we need to have a separate Parent child table which consist of four columns like ancestorkey, memberkey, distance, leaf.
From the above column i can understand the meaning like
For Ancestorkey-->Managerid
Memberkey------->Employeeid
But i couldnt get with the meaning for distance column as the meaning suggest like a distance b/w the two and leaf column as the meaning suggest like a leaf member. which leaf member does it refer.
I also referred the below link then too couldnt get the meaning for it
http://www.rittmanmead.com/2010/08/oracle-bi-ee-11g-parent-child-hierarchies-differing-aggregations/+
How i can form the parent child table for the BI from my above three tables of HRMS.
Thanks
Regards,
SaroHi friends,
I think i found a link of doing it
http://prasadmadhasi.com/2011/11/15/hierarchies-parent-child-hierarchy-in-obiee-11g/
Let me try this and will update accordingly.
Thanks for your views.
Regards,
Saro -
Problem with saving Parent - Child View Objects in ADF 11g.
Hi Every one,
I have a requirment, something like I will be displaying some data on my jsff screen based on one Transient View Object. Whenever user clicks on Save button, I have to do following steps in my AMImpl.
-> Preapre dynamically Parent View Object Rows based on some logic
-> Prepare dynamically Child View object Rows and invoke insertRow method on respective child view object.
When I say commit() First Parent ViewObject data need to be saved and then Child View object data has to be saved. I am having Parent - Child Key relation ship btw these two ViewObjects. Some how I am populating the Parent Primary key in the Child View Object. Please suggest me If there is any other alternative to this.
ThanksI got the solution, Enabling the check box option for Master - Detail Entity association (CompositionAssociation -> Cascade Update Key Attributes) resolved the issue.
Thanks -
Delete only the child object and not the parent object
Hi,
I have the below code:-
TAnswer
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "question_id", nullable = false)
// @Cascade(value=CascadeType.ALL)
public TQuestion getTQuestion() {
return this.TQuestion;
} TQuestion
@OneToMany(fetch = FetchType.LAZY, mappedBy = "TQuestion", orphanRemoval = true)
@Cascade(value=CascadeType.ALL)
/*@Cascade({org.hibernate.annotations.CascadeType.SAVE_UPDATE,
org.hibernate.annotations.CascadeType.DELETE,
org.hibernate.annotations.CascadeType.MERGE,
org.hibernate.annotations.CascadeType.PERSIST,
org.hibernate.annotations.CascadeType.DELETE_ORPHAN})*/
public List<TAnswer> getTAnswers() {
return this.TAnswers;
In Java:-
public void removeAnswers(TQuestion question)
throws ApplicationException {
List<TAnswer> answerList = question.getTAnswers();
deleteall(answerList);
public void deleteall(Collection objects) {
try {
getHibernateTemplate().deleteAll(objects);
getHibernateTemplate().flush();
} catch (Exception e) {
throw new ServerSystemException(ErrorConstants.DATA_LAYER_ERR, e);
} Here the "deleteall" will delete both the answer records and question records, I don't want the questions
records to be deleted. I have tried making the question as null when we set the answer object to be passed for delete
bit still it is deleting the question records as well.How to achieve the above in deleting only the answer (child) records
and not the question(parent) record? Is there any thing we need to do with @Cascade for Question object? Please clarify.
Thanks.What does deleteAll do, it doesn't look like a JPA method. You might want to ask your question on your provider forum, or use straight JPA methods as a simple EntityManager.remove(answer) on each answer in the collection should work.
Regards,
Chris -
Business Scenario- We have a parent organization with 6 different Business Units.One BU requires 9 stages for for Opportunity(Tender) Tracking.The client requirement is to show the basic details of the tender at the header level and to show details specific to individual sales stage as different tabs.There will be multiple opportunity members added as opportunity team and will be responsible for capturing details specific to individual sales stage(tab). The Tab should be enabled and disabled based on the role. Reporting is required against each stage with specific fields of child objects against each opportunity.
We created multiple children entities under the oportunity(one to many mapping) but we are unable to add more than 3 child objects for a primary object for reporting purpose.
Kindly suggest what needs to be done to meet the requirementCan you provide the exact steps you took to "created multiple children entities under the oportunity" ?
Jani Rautiainen
Fusion Applications Developer Relations
https://blogs.oracle.com/fadevrel/ -
Parent/Child BC4J Entity Object Sequence # Generation
If anyone can help us in this we greatly appreciate it. We are using DBSequence data type to poplulate the parent entity with the sequence #; however, we need to populate the child entity with the same sequence #.
We have a DB Trigger for every insert of the parent's key and it's working great but what do we need to do for populating the child record.
Is there a way to get the sequence # as a part of the this code for the child entity object.
protected void create(AttributeList attributeList)
super.create(attributeList);
SequenceImpl mySeq = new SequenceImpl("MY_SEQ",getDBTransaction());
setMyObjectId(mySeq.getSequenceNumber());
Thank you,
KamranWell,
I still can't insert the parent's primary key as a forign key automatically. Like in the Dept/Emp situation, I need to setup the supporting Impl files so it would insert the Dept No automatically as a part of the Employee creation.
New info : Here is a sample of what I am trying to accomplish. Sorry I could
have been more clear:
I am sending you my Workspace using Scott's table Dept and Emp. In my JSP file,
The user needs to input the Department information and some of the Employee
info, but the same deptno generated for the Dept record needs to be populated
for the Employee at the time of submit.
Please let me know if you need anything else.
Thank you,
Kamran
Creat_Emp.jsp
<%@ taglib uri="/webapp/DataTags.tld" prefix="jbo" %>
<%@ page contentType="text/html;charset=windows-1252"%>
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=windows-1252">
<TITLE>
Hello World
</TITLE>
</HEAD>
<BODY>
<jbo:ApplicationModule id="Mypackage2Module"
configname="mypackage2.Mypackage2Module.Mypackage2ModuleLocal"
releasemode="Stateful" />
<jbo:DataSource id="Dept" appid="Mypackage2Module" viewobject="DeptView" />
<jbo:DataSource id="Emp" appid="Mypackage2Module" viewobject="EmpView" />
<jbo:Row id="myrow" datasource="Dept" action="Create" >
<jbo:SetAttribute dataitem="*" />
</jbo:Row>
<jbo:Row id="myrow5" datasource="Emp" action="Create" >
<jbo:SetAttribute dataitem="*" />
</jbo:Row>
<form NAME="sForm" action="Submit.jsp" >
<td><h3> DAAO <br> New Dept Entry Screen</h3></td>
<tr>
<TABLE bgColor="#c0c0c0" cellspacing="0" cellpadding="0" border="0" frame="box"
style="WIDTH: 530px; HEIGHT: 34px" >
<TR>
<TD><font color=darkyellow >Dept No:<br><jbo:InputText datasource="Dept"
dataitem="Deptno" ></jbo:InputText></TD>
<TD><font color=darkyellow >Dept Name:<br><jbo:InputText datasource="Dept"
dataitem="Dname" ></jbo:InputText></TD>
<TD><font color=darkyellow >Dept Location:<br><jbo:InputText datasource="Dept"
dataitem="Loc" ></jbo:InputText></TD>
</TABLE>
<TABLE bgColor="#c0c0c0" cellspacing="0" cellpadding="0" border="0" frame="box"
style="WIDTH: 530px; HEIGHT: 34px" >
<TR>
<TD><font color=darkyellow >Emp Dept No:<br><jbo:InputText datasource="Emp"
dataitem="Deptno" ></jbo:InputText></TD>
<TD><font color=darkyellow >Emp Id<jbo:InputText datasource="Emp"
dataitem="Empno" ></jbo:InputText>
<TD><font color=darkyellow >Emp Name:<br><jbo:InputText datasource="Emp"
dataitem="Ename" ></jbo:InputText></TD>
<TD><font color=darkyellow >Emp Job:<br><jbo:InputText datasource="Emp"
dataitem="Job" ></jbo:InputText></TD>
</TR>
</TABLE>
<TABLE bgColor="#c0c0c0" cellspacing="0" cellpadding="0" border="0" frame="box"
style="WIDTH: 530px; HEIGHT: 34px" >
<TR>
<TD><font color=darkyellow >Emp Mgr:<br><jbo:InputText datasource="Emp"
dataitem="Mgr" ></jbo:InputText></TD>
</TABLE>
<input name="RowKeyValue" type="hidden" value="<jbo:ShowValue
datasource="Emp" dataitem="RowKey"/>" />
<input type="submit" value="Save" /> <input type="reset" value="Clear
Screen"/> <input type="BUTTON" value="Q&A" onClick="Create_new_qa.jsp">
</form>
<form NAME="qForm" action="Create_New_Qa2.jsp" ></TD>
<input type="submit" value="Q&A" />
</form>
</body>
<jbo:ReleasePageResources releasemode="Stateless" />
</html>
Here is the submit.jsp
<%@ page language="java" contentType="text/html;charset=WINDOWS-1252" %>
<html xmlns:jbo="foo">
<body>
<center>
<br>
<%@ taglib uri="/webapp/DataTags.tld" prefix="jbo" %>
<br>
<jbo:ApplicationModule id="Mypackage2Module" configname="mypackage2.Mypackage2Module.Mypackage2ModuleLocal" releasemode="Stateful" />
<jbo:DataSource id="Dept" appid="Mypackage2Module" viewobject="DeptView" />
<jbo:DataSource id="Emp" appid="Mypackage2Module" viewobject="EmpView" />
<jbo:Row id="myrow" datasource="Dept" action="create" >
<jbo:SetAttribute dataitem="*" />
</jbo:Row>
<jbo:Row id="myrow5" datasource="Emp" action="Create" >
<jbo:SetAttribute dataitem="*" />
</jbo:Row>
<%
try
%>
<jbo:PostChanges appid="Mypackage2Module" />
<jbo:Commit appid="Mypackage2Module"/>
<p><font face="Arial, Helvetica, sans-serif"><b><font color="006699">DAAO Case Saved Successfully! </b></font></font> </p>
<%
catch(Exception exc)
%>
<title>this page will be displayed</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</head>
<body bgcolor="#FFFFFF">
<h1> Attenion the following error has occured:</h1><br>
<%
String error_msg = exc.getMessage();
if(exc instanceof oracle.jbo.JboException)
oracle.jbo.JboException jboex = (oracle.jbo.JboException)exc;
String sMsg = jboex.getDetailMessage();
out.println("<center>JBO Error:" + sMsg + "</center>");
// grab exception object. type cast to jbo object then get details
// parse details for specific error
Object[] details = jboex.getDetails();
if ( sMsg.startsWith("JBO-26041") )
if (
(details !=null)
&& (details.length >0 )
&& (details[0] instanceof java.sql.SQLException )
java.sql.SQLException sourceException = (java.sql.SQLException)(details[0]);
int sqlErrorCode = sourceException.getErrorCode();
if (sqlErrorCode == 1400)
out.println("<br><br><b><font color=\"006699\">One or more of the following required fields (Labeled in Red) have not been entered: </b></font></center><b>");
else
out.println("<br><br><b><font color=\"006699\"> Already exist on our system!! </b></font></center><b>");
if ( sMsg.startsWith("JBO-26041") )
else // unknown JBO exception
} //JBO exception instance
%>
<jbo:ReleasePageResources releasemode="Stateless"/>
<%
return;
%>
<br>
<br>
<form action="main.html" method= onclick><input type="submit" value="Back to Main"></form>
</center>
</body>
<jbo:ReleasePageResources releasemode="Stateless"/>
</html> -
How to reference the Parent view Object attribute in Child View object
Hi , I have the requirememt to generate Tree like struture to display Salary from joining date to retirement date in yearly form.I have writtent two Pl/SQL function to return parent node and child nodes(based on selected year).
1.First function --> Input paramter (employee id, retirement date , joining date) --> return parent node row with start_date and end_date
2. 2nd function --> input paarmter(employee id, startDate, end_date) --> return child node based on selected parent node i.e. start date and end date
I have created two ADF view object based on two function return
Parent Node --> select * from Table( EUPS.FN_GET_CONTR_SAL_BY_YR(employeeId,retirement Date, dateOf joining)) ;
Child Node --> select * FROM TABLE( EUPS.FN_GET_CONTR_SAL_FOR_YEAR( employeId,startDate, endDate) ) based on selected parent node.
I am giving binding variable as input for 2nd function (child node) . I don't know how to reference the binding variable value in child view from parent view.
Like I have to refernce employeId,startDate, endDate values in 2nd function from parent view object. some thing like parentNode.selectedStart_date parentNode.employeeId.
I know we can achive this writing the code in backing bean.But i want to know how can we refernce parent view object attribute values in child view object using Groovy or otherway?
I will appreciate your help.
ThanksI have two view com.ContractualSalaryByYearlyView for Parent Node and com.ContractualSalaryByYearlyView for child Node.
I have created view link(ContractualSalYearlyByYearViewLink) betweem two view by giving common field empId, stDate , endDate.(below is the view link xml file).
I tried give the binding attribute values using parent object reference like below in com.ContractualSalaryByYearlyView xml file but getting error
Variable ContractualSalaryByYearlyView not recognized.I think i am using groovy expression.
Thanks for quick response.
com.ContractualSalaryByYearlyView xml
<ViewObject
<DesignTime>
<Attr Name="_isExpertMode" Value="true"/>
</DesignTime>
<Variable
Name="empId"
Kind="where"
Type="java.lang.Integer">
<TransientExpression><![CDATA[adf.object.ContractualSalaryByYearlyView.EmpId]]></TransientExpression>
</Variable>
ContractualSalYearlyByYearViewLink.xml file
<ViewLinkDefEnd
Name="ContractualSalaryByYearlyView"
Cardinality="1"
Owner="com.ContractualSalaryByYearlyView"
Source="true">
<DesignTime>
<Attr Name="_finderName" Value="ContractualSalaryByYearlyView"/>
<Attr Name="_isUpdateable" Value="true"/>
</DesignTime>
<AttrArray Name="Attributes">
<Item
Value="com.ContractualSalaryByYearlyView.EmpId"/>
<Item
Value="com.ContractualSalaryByYearlyView.StDate"/>
<Item
Value="com.ContractualSalaryByYearlyView.EndDate"/>
</AttrArray>
</ViewLinkDefEnd>
<ViewLinkDefEnd
Name="ContractualSalaryForYearView"
Cardinality="-1"
Owner="com.ContractualSalaryForYearView">
<DesignTime>
<Attr Name="_finderName" Value="ContractualSalaryForYearView"/>
<Attr Name="_isUpdateable" Value="true"/>
</DesignTime>
<AttrArray Name="Attributes">
<Item
Value="com.ContractualSalaryForYearView.EmpId"/>
<Item
Value="com.ContractualSalaryForYearView.StDate"/>
<Item
Value="com.ContractualSalaryForYearView.EndDate"/>
</AttrArray>
</ViewLinkDefEnd> -
Help needed in retrieving parent child relationship values
Hi,
I have a requirement to get parent child relationship values as below.
Ex: Address table
cont cont_code state state_code
C1 10 S1 1
C1 10 S2 2
C1 10 S3 3
C2 20 S4 4
C2 20 S5 5
C3 30 S6 6
C3 30 S7 7
C3 30 S8 8
I want a result of country/state and corresponding code like below.
corresponding states should be displayed under each country with some space appended to it.
Geography code
C1 10
S1 1
S2 2
S3 3
C2 20
S4 4
S5 5
C3 30
S6 6
S7 7
S8 8
I am using oracle 10g version.
Thanks in advance.Hi,
When you post formatted text (like your output) on this site, type these 6 characters:
\(small letters only, inside curly brackets) before and after each section of formatted text, to preserve spacing.
I think you're saying that you want this output:GEOGRAPHY CODE
C1 10
S1 1
S2 2
S3 3
C2 20
S4 4
S5 5
C3 30
S6 6
S7 7
S8 8
If so, UNION, as Hoek suggested, is a good way.
GROUP BY ROLLUP is more efficient, but harder to understand:SELECT CASE
WHEN GROUPING (state) = 1
THEN cont
ELSE ' ' || state
END AS geography
, CASE
WHEN GROUPING (state) = 1
THEN MAX (cont_code)
ELSE MAX (state_code)
END AS code
FROM t
GROUP BY cont
, ROLLUP (state)
ORDER BY cont
, state NULLS FIRST
By the way, this looks like a bad table design.
In a relational database, the fact that the name 'C1' belongs to cont_code 10 should only be stored in one place. You have the same information on 3 separate rows.
Also, if 'C1' and 'S1' are both names, they should probably be in the same column, so that (to give just one example) you can find the information about 'x1' without knowing if it is a cont or a state.
A better design would be.NAME CODE PARENT DSCR
==== ==== ====== ====
C1 10 CONT
S1 1 10 STATE
S2 2 10 STATE
S3 3 10 STATE
C2 20 CONT
S4 4 20 STATE
S5 5 20 STATE
C3 30 CONT
S6 6 30 STATE
S7 7 30 STATE
S8 8 30 STATE
If the data is this simple, then the dscr column isn't needed. Whether parent is NULL or not tells whether the rows represents a cont or a state.
To get the results you want from a table like this, you could use CONNECT BY. Using either UNION or ROLLUP, you have to know, at the time you write the query, how many levels there will be in the parent-child tree, and the length of the code is proportional to that depth, and the table has to be changed if you ever need to add another level. CONNECT BY can handle any number of levels, and the length and complexity of the code is the same whether you have just 2 levels (countries and strates), or 7 levels (continents, regions, countiries, states, districts, cities and neighborhoods) or 72 levels. The table doesn't need any more columns, no matter how deep the tree gets.
Edited by: Frank Kulash on Sep 16, 2010 11:54 AM -
How to build a query across parent and child object fields?
As a part of an Integration Requirement, I need to query Opportunity records that have been Modified after a specific date and time?
Now, Opportunity has a child object called ProductRevenue with a one to many relationship. Is there anyway I can construct a querypage that will fetch records whose Opportunity fields 'OR' its child ProductRevenue's fields have been modified after a specific date and time?
I have tried using the SearchSpec argument, but it does not let me query across child object fields.
For eg:-
ObjOpptyQueryPageInput.ListOfOpportunity.Opportunity.searchspec = "([ModifiedDate] > '01/01/2013 00:00:00') OR ([ProductRevenueData.ModifiedDate] >= '01/01/2013 00:00:00')";
[This above code written in C# thew me an error saying - The object Opportunity does not have an integration component called - ProductRevenueData.ModifiedDate.]
Any help will be greatly appreciated. Thank you.Hi,
As far as I know this can't be done at once because you have to consider :
- Every Opportunity and their time-limited ProductRevenues
AND
- Time-limited Opportunities
If you want to achieve this, you have to consider the 2 datasets separately and make your first query :
ObjOpptyQueryPageInput.ListOfOpportunity.Opportunity.searchspec = "([ModifiedDate] >= '01/01/2013 00:00:00')";
but also another query with the restriction on the ProductRevenue Searchspec.
This shouldn't be too hard because the searchspec functionality is present at each level :
- ListOfOpportunity -> Opportunity (the top-level that you used for your query)
- ListOfOpportunity -> Opportunity -> ListOfProductRevenue -> ProductRevenue (the sub-level that you should use for the second query)
Then in your C# code, you merge the 2 datasets and you end up with your expected result.
Hope this helps,
Charles.
http://www.dubant.com
Maybe you are looking for
-
I will try not to rant here that much. I have been a happy mac user since september of 2006. I have been a very unhappy frustrated mac user since last week. I bragged about how great the mac is. how it is for everyone. I have converted 2 families ove
-
Dual Monitors with Zotac DisplayPort to Dual HDMI Adaptor?
Has anyone had the chance to try the "ZOTAC DisplayPort to Dual HDMI Adaptor" with the MacBook Pro's yet? http://www.zotacusa.com/zotac-displayport-to-dual-hdmi-adaptor.html I'm currently using a Mini DisplayPort to DisplayPort adapter to connect to
-
Why is my import from DVD-R going soooo SLOW??
OK, I'm very new in the Mac world and am still trying to move my photos from my PC. I burned all of the photos to a DVD-R using the Kodak gallery program. I have 3 DVDs of photos. Now I am in the process of importing into iPhoto. I opened iPhoto, ins
-
Copy paste a front panel object to the very same xy location
Hello, Just a practical question, but I would need this kind of feature very often: How can I copy-paste a front panel object to the very same location? Lets consider I have a TAB container, and on the first page, I have a Graph. I would like to make
-
Vingette, from distortion filter lens correction
Lens correction, and therefore vingette does not apper in my distort filter drop down menu in cs5????? can I put this in to this filter or is it somewhere else. thaanks Denise