HSlider trackSkin parent is null
Hi
I'm creating a programmatic skin for a slider track that is based on the value of the slider. The examples I've seen get the containing control from the skin's parent, and indeed for a button skin this works fine, but for my trackSkin, the parent is always null.
Is there something special I need to do in this case?
Cheers
This is wierd - I was checking parent yesterday and it was always null - today it's not null, so the proposed solution works.
But I'm still comfused...
Ah well
Cheers
Similar Messages
-
Hi guys,
I'm developing a simple Applet application with JDK 1.3.1.
All of codes are the following,
DemoApplet.java
public class DemoApplet extends Applet {
private static final long serialVersionUID = -371112038768840393;
public DemoApplet() {
BorderLayout gridLayout = new BorderLayout();
setLayout(gridLayout);
add(new DemoPanel(), BorderLayout.CENTER);
public void init() {
}DemoPanel.java
public class DemoPanel extends Panel {
private static final long serialVersionUID = -5992125460349250223;
private DemoPopupMenu popupMenu = new DemoPopupMenu();
public DemoPanel() {
addMouseListener(mouseAdapter);
private MouseAdapter mouseAdapter = new MouseAdapter() {
public void mouseClicked(MouseEvent e) {
if (SwingUtilities.isRightMouseButton(e)) {
popupMenu
.show((DemoPanel) e.getComponent(), e.getX(), e.getY());
}DemoPopupMenu .java
public class DemoPopupMenu extends PopupMenu {
private static final long serialVersionUID = -7751149413579159572;
private Menu menu = new Menu("PopuMenu");
public DemoPopupMenu() {
add(menu);
}When I run DemoApplet with appletviewer, an exception was thrown:
Exception occurred during event dispatching:
java.lang.NullPointerException: parent is null
at java.awt.PopupMenu.show(PopupMenu.java:102)
at test.demo.DemoPanel$1.mouseClicked(DemoPanel.java:23)
at java.awt.Component.processMouseEvent(Component.java:3713)
at java.awt.Component.processEvent(Component.java:3539)
at java.awt.Container.processEvent(Container.java:1159)
at java.awt.Component.dispatchEventImpl(Component.java:2588)
at java.awt.Container.dispatchEventImpl(Container.java:1208)
at java.awt.Component.dispatchEvent(Component.java:2492)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:334)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:126)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:93)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:88)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:80) But if I changed all of PopupMenu/Menu to JPopupMenu/JMenu, all was OK.
Although the old AWT codes aren't recommended, I don't think the application is wrong.
I'm puzzled by the matter.
I wish some friend would explain the matter.
Thanks in advance!
a cup of Java, cheers!
Sha Jiang
Edited by: jiangshachina on Oct 29, 2007 4:44 PMOh, I get it.
Thanks for the reply.
Rewards a Duck star :-D
You never added the popupMenu to anything. Therefore, it has no parent and is not part of any component hierarchy.With the error output, I known the DemoPopupMenu need a "parent" component.
But I simple think DemoPanel is the parent for DemoPopupMenu,
because DemoPopupMenu is included by DemoPanel (so foolish!)
Also, you should not use isRightMouseButton() for handling popup actions.
There is a method called isPopupTrigger() in the MouseEvent class.
Call this in the mousePressed() and mouseReleased() methods of your MouseListener (instead of mouseClicked).I know the method isPopupTrigger().
In fact, at the beginning, I used isPopupTrigger(), but it didn't work.
Whether I right-click or left-click, both of the values of isPopupTrigger() are "false".
Then I have to redirect to isRightMouseButton() :-( -
Getting the slider that a trackskin is attached to?
I've got a slider, and it has a custom TrackSkin class. In that class, I would like to get a reference to the slider (so I can move its thumb around). Is it possible? parent is null.
Hi Again Chucksott
# "But on going to some sites, Ffox/Android starts popping up the onscreen keyboard. Then the keyboard dock stops working. Is this an Android problem or a Firefox problem" I use firefox for android with a keyboard on my Samsung Tab S without difficulty. This could be an Android or a Firefox problem or both. '''Again as per my previous reply to you letting us know your version of Android and which sites are affected would be super helpful.'''
cheers once more!
...Roland -
Problem with trees(Duplication of the parent node in creation of children)
Hi guys i am experiencing a slight problem with the creation of trees.Here is a clear explanation of my program.I created a program that generates edges from a set of datapoints then use each and every edge that is generated to create multiple trees with the edge as the rootnode for each and every tree.Everything up to so far everything went well but the problem comes when i want the program to pick every single tree and traverse through the set of generated edges to create the children of a tree.What it does at the moment for each tree is returning the a duplication of the parent node as the child nodes and that is a problem.Can anyone related with this problem help.Your help will be appreciated.
The code
TreeNode class
package SPO;
import java.util.*;
public class TreeNode
Edge edge;
TreeNode node;
Vector childrens = new Vector();
public TreeNode(Edge edge)
this.edge = edge;
public synchronized void insert(Edge edge)
if(edge.fromNode == this.edge.toNode)
if(node == null )
node = new TreeNode(edge);
childrens.add(node);
else
node.insert(edge);
childrens.add(node);
Tree class
package SPO;
import java.util.*;
public class Tree
TreeNode rootNode;
public Tree()
rootNode = null;
public Tree[] createTrees(Vector initTrees,Vector edges)
Tree [] trees = new Tree[initTrees.size()];
for(int c = 0;c < trees.length;c++)
trees[c] = (Tree)initTrees.elementAt(c);
for(int i = 0;i < trees.length;i++)
for(int x = 0;x < edges.size();x++)
Vector temp = (Vector)edges.elementAt(x);
for(int y = 0;y < temp.size();y++)
trees.insertNode((Edge)temp.elementAt(y));
return trees;
public void printTree(Tree tree)
System.out.print("("+tree.rootNode.edge.fromNode.getObjName()+","+tree.rootNode.edge.toNode.getObjName()+")");
Vector siblings = tree.rootNode.childrens;
for(int i = 0; i < siblings.size();i++)
TreeNode node = (TreeNode)siblings.elementAt(i);
System.out.print("("+node.edge.fromNode.getObjName()+","+node.edge.toNode.getObjName()+")");
System.out.println();
public Vector initializeTrees(Vector edges)
Vector trees = new Vector();
for(int i = 0;i < edges.size();i++)
Vector temp = (Vector)edges.elementAt(i);
for(int j = 0;j < temp.size();j++)
Tree tree = new Tree();
tree.insertNode((Edge)temp.elementAt(j));
trees.add(tree);
return trees;
public synchronized void insertNode(Edge edge)
if(rootNode == null)
rootNode = new TreeNode(edge);
else
rootNode.insert(edge);
EdgeGenerator class
package SPO;
import java.util.*;
import k_means.*;
public class EdgeGenerator
public EdgeGenerator()
public Vector createEdges(Vector dataPoints)
//OrderPair orderPair = new OrderPair();
Vector edges = new Vector();
for(int i = 0;i < dataPoints.size()-1 ;i++)
Vector temp = new Vector();
for(int j = i+1;j < dataPoints.size();j++)
//Create an order of edges
Edge edge = new Edge((DataPoint)dataPoints.elementAt(i),(DataPoint)dataPoints.elementAt(j));
temp.add(edge);
edges.add(temp);
return edges;
Edge class
package SPO;
import k_means.*;
public class Edge
public DataPoint toNode;
public DataPoint fromNode;
public Edge(DataPoint x,DataPoint y)
if (x.getX() > y.getX())
this.fromNode = x;
this.toNode = y;
else
this.fromNode=y;
this.toNode = x;
Entry Point
package SPO;
import java.util.*;
import k_means.*;
public class Tester {
public static void main(String[] args)
Vector dataPoints = new Vector();
dataPoints.add(new DataPoint(140, "Orange"));
dataPoints.add(new DataPoint(114.2, "Lemmon"));
dataPoints.add(new DataPoint(111.5, "Coke"));
dataPoints.add(new DataPoint(104.6, "Pine apple"));
dataPoints.add(new DataPoint(94.1, "W grape"));
dataPoints.add(new DataPoint(85.2, "Appletizer"));
dataPoints.add(new DataPoint(84.8, "R Grape"));
dataPoints.add(new DataPoint(74.2, "Sprite"));
dataPoints.add(new DataPoint(69.2, "Granadilla"));
dataPoints.add(new DataPoint(59, "Strawbery"));
dataPoints.add(new DataPoint(45.5, "Stone"));
dataPoints.add(new DataPoint(36.3, "Yam"));
dataPoints.add(new DataPoint(27, "Cocoa"));
dataPoints.add(new DataPoint(13.8, "Pawpaw"));
EdgeGenerator eg = new EdgeGenerator();
Vector edges = eg.createEdges(dataPoints);
Tree treeMaker = new Tree();
Vector partialTrees = treeMaker.initializeTrees(edges);
Tree [] trees = treeMaker.createTrees(partialTrees,edges);
for(int i = 0;i < trees.length;i++)
treeMaker.printTree(trees[i]);
The program output
Each and every "@" symbol represents the start of a tree
@(Orange,Lemmon)(Lemmon,Coke)(Lemmon,Coke)(Lemmon,Coke)(Lemmon,Coke)(Lemmon,Coke)(Lemmon,Coke)(Lemmon,Coke)(Lemmon,Coke)(Lemmon,Coke)(Lemmon,Coke)(Lemmon,Coke)(Lemmon,Coke)
@(Orange,Coke)(Coke,Pine apple)(Coke,Pine apple)(Coke,Pine apple)(Coke,Pine apple)(Coke,Pine apple)(Coke,Pine apple)(Coke,Pine apple)(Coke,Pine apple)(Coke,Pine apple)(Coke,Pine apple)(Coke,Pine apple)
@(Orange,Pine apple)(Pine apple,W grape)(Pine apple,W grape)(Pine apple,W grape)(Pine apple,W grape)(Pine apple,W grape)(Pine apple,W grape)(Pine apple,W grape)(Pine apple,W grape)(Pine apple,W grape)(Pine apple,W grape)
@(Orange,W grape)(W grape,Appletizer)(W grape,Appletizer)(W grape,Appletizer)(W grape,Appletizer)(W grape,Appletizer)(W grape,Appletizer)(W grape,Appletizer)(W grape,Appletizer)(W grape,Appletizer)
@(Orange,Appletizer)(Appletizer,R Grape)(Appletizer,R Grape)(Appletizer,R Grape)(Appletizer,R Grape)(Appletizer,R Grape)(Appletizer,R Grape)(Appletizer,R Grape)(Appletizer,R Grape)
@(Orange,R Grape)(R Grape,Sprite)(R Grape,Sprite)(R Grape,Sprite)(R Grape,Sprite)(R Grape,Sprite)(R Grape,Sprite)(R Grape,Sprite)
@(Orange,Sprite)(Sprite,Granadilla)(Sprite,Granadilla)(Sprite,Granadilla)(Sprite,Granadilla)(Sprite,Granadilla)(Sprite,Granadilla)
@(Orange,Granadilla)(Granadilla,Strawbery)(Granadilla,Strawbery)(Granadilla,Strawbery)(Granadilla,Strawbery)(Granadilla,Strawbery)
@(Orange,Strawbery)(Strawbery,Stone)(Strawbery,Stone)(Strawbery,Stone)(Strawbery,Stone)
@(Orange,Stone)(Stone,Yam)(Stone,Yam)(Stone,Yam)
@(Orange,Yam)(Yam,Cocoa)(Yam,Cocoa)
@(Orange,Cocoa)(Cocoa,Pawpaw)
@(Orange,Pawpaw)
@(Lemmon,Coke)(Coke,Pine apple)(Coke,Pine apple)(Coke,Pine apple)(Coke,Pine apple)(Coke,Pine apple)(Coke,Pine apple)(Coke,Pine apple)(Coke,Pine apple)(Coke,Pine apple)(Coke,Pine apple)(Coke,Pine apple)
@(Lemmon,Pine apple)(Pine apple,W grape)(Pine apple,W grape)(Pine apple,W grape)(Pine apple,W grape)(Pine apple,W grape)(Pine apple,W grape)(Pine apple,W grape)(Pine apple,W grape)(Pine apple,W grape)(Pine apple,W grape)
@(Lemmon,W grape)(W grape,Appletizer)(W grape,Appletizer)(W grape,Appletizer)(W grape,Appletizer)(W grape,Appletizer)(W grape,Appletizer)(W grape,Appletizer)(W grape,Appletizer)(W grape,Appletizer)
@(Lemmon,Appletizer)(Appletizer,R Grape)(Appletizer,R Grape)(Appletizer,R Grape)(Appletizer,R Grape)(Appletizer,R Grape)(Appletizer,R Grape)(Appletizer,R Grape)(Appletizer,R Grape)
@(Lemmon,R Grape)(R Grape,Sprite)(R Grape,Sprite)(R Grape,Sprite)(R Grape,Sprite)(R Grape,Sprite)(R Grape,Sprite)(R Grape,Sprite)
@(Lemmon,Sprite)(Sprite,Granadilla)(Sprite,Granadilla)(Sprite,Granadilla)(Sprite,Granadilla)(Sprite,Granadilla)(Sprite,Granadilla)
@(Lemmon,Granadilla)(Granadilla,Strawbery)(Granadilla,Strawbery)(Granadilla,Strawbery)(Granadilla,Strawbery)(Granadilla,Strawbery)
@(Lemmon,Strawbery)(Strawbery,Stone)(Strawbery,Stone)(Strawbery,Stone)(Strawbery,Stone)
@(Lemmon,Stone)(Stone,Yam)(Stone,Yam)(Stone,Yam)
@(Lemmon,Yam)(Yam,Cocoa)(Yam,Cocoa)
@(Lemmon,Cocoa)(Cocoa,Pawpaw)
@(Lemmon,Pawpaw)
@(Coke,Pine apple)(Pine apple,W grape)(Pine apple,W grape)(Pine apple,W grape)(Pine apple,W grape)(Pine apple,W grape)(Pine apple,W grape)(Pine apple,W grape)(Pine apple,W grape)(Pine apple,W grape)(Pine apple,W grape)
@(Coke,W grape)(W grape,Appletizer)(W grape,Appletizer)(W grape,Appletizer)(W grape,Appletizer)(W grape,Appletizer)(W grape,Appletizer)(W grape,Appletizer)(W grape,Appletizer)(W grape,Appletizer)
@(Coke,Appletizer)(Appletizer,R Grape)(Appletizer,R Grape)(Appletizer,R Grape)(Appletizer,R Grape)(Appletizer,R Grape)(Appletizer,R Grape)(Appletizer,R Grape)(Appletizer,R Grape)
@(Coke,R Grape)(R Grape,Sprite)(R Grape,Sprite)(R Grape,Sprite)(R Grape,Sprite)(R Grape,Sprite)(R Grape,Sprite)(R Grape,Sprite)
@(Coke,Sprite)(Sprite,Granadilla)(Sprite,Granadilla)(Sprite,Granadilla)(Sprite,Granadilla)(Sprite,Granadilla)(Sprite,Granadilla)
@(Coke,Granadilla)(Granadilla,Strawbery)(Granadilla,Strawbery)(Granadilla,Strawbery)(Granadilla,Strawbery)(Granadilla,Strawbery)
@(Coke,Strawbery)(Strawbery,Stone)(Strawbery,Stone)(Strawbery,Stone)(Strawbery,Stone)
@(Coke,Stone)(Stone,Yam)(Stone,Yam)(Stone,Yam)
@(Coke,Yam)(Yam,Cocoa)(Yam,Cocoa)
@(Coke,Cocoa)(Cocoa,Pawpaw)
@(Coke,Pawpaw)
@(Pine apple,W grape)(W grape,Appletizer)(W grape,Appletizer)(W grape,Appletizer)(W grape,Appletizer)(W grape,Appletizer)(W grape,Appletizer)(W grape,Appletizer)(W grape,Appletizer)(W grape,Appletizer)
@(Pine apple,Appletizer)(Appletizer,R Grape)(Appletizer,R Grape)(Appletizer,R Grape)(Appletizer,R Grape)(Appletizer,R Grape)(Appletizer,R Grape)(Appletizer,R Grape)(Appletizer,R Grape)
@(Pine apple,R Grape)(R Grape,Sprite)(R Grape,Sprite)(R Grape,Sprite)(R Grape,Sprite)(R Grape,Sprite)(R Grape,Sprite)(R Grape,Sprite)
@(Pine apple,Sprite)(Sprite,Granadilla)(Sprite,Granadilla)(Sprite,Granadilla)(Sprite,Granadilla)(Sprite,Granadilla)(Sprite,Granadilla)
@(Pine apple,Granadilla)(Granadilla,Strawbery)(Granadilla,Strawbery)(Granadilla,Strawbery)(Granadilla,Strawbery)(Granadilla,Strawbery)
@(Pine apple,Strawbery)(Strawbery,Stone)(Strawbery,Stone)(Strawbery,Stone)(Strawbery,Stone)
@(Pine apple,Stone)(Stone,Yam)(Stone,Yam)(Stone,Yam)
@(Pine apple,Yam)(Yam,Cocoa)(Yam,Cocoa)
@(Pine apple,Cocoa)(Cocoa,Pawpaw)
@(Pine apple,Pawpaw)
@(W grape,Appletizer)(Appletizer,R Grape)(Appletizer,R Grape)(Appletizer,R Grape)(Appletizer,R Grape)(Appletizer,R Grape)(Appletizer,R Grape)(Appletizer,R Grape)(Appletizer,R Grape)
@(W grape,R Grape)(R Grape,Sprite)(R Grape,Sprite)(R Grape,Sprite)(R Grape,Sprite)(R Grape,Sprite)(R Grape,Sprite)(R Grape,Sprite)
@(W grape,Sprite)(Sprite,Granadilla)(Sprite,Granadilla)(Sprite,Granadilla)(Sprite,Granadilla)(Sprite,Granadilla)(Sprite,Granadilla)
@(W grape,Granadilla)(Granadilla,Strawbery)(Granadilla,Strawbery)(Granadilla,Strawbery)(Granadilla,Strawbery)(Granadilla,Strawbery)
@(W grape,Strawbery)(Strawbery,Stone)(Strawbery,Stone)(Strawbery,Stone)(Strawbery,Stone)
@(W grape,Stone)(Stone,Yam)(Stone,Yam)(Stone,Yam)
@(W grape,Yam)(Yam,Cocoa)(Yam,Cocoa)
@(W grape,Cocoa)(Cocoa,Pawpaw)
@(W grape,Pawpaw)
@(Appletizer,R Grape)(R Grape,Sprite)(R Grape,Sprite)(R Grape,Sprite)(R Grape,Sprite)(R Grape,Sprite)(R Grape,Sprite)(R Grape,Sprite)
@(Appletizer,Sprite)(Sprite,Granadilla)(Sprite,Granadilla)(Sprite,Granadilla)(Sprite,Granadilla)(Sprite,Granadilla)(Sprite,Granadilla)
@(Appletizer,Granadilla)(Granadilla,Strawbery)(Granadilla,Strawbery)(Granadilla,Strawbery)(Granadilla,Strawbery)(Granadilla,Strawbery)
@(Appletizer,Strawbery)(Strawbery,Stone)(Strawbery,Stone)(Strawbery,Stone)(Strawbery,Stone)
@(Appletizer,Stone)(Stone,Yam)(Stone,Yam)(Stone,Yam)
@(Appletizer,Yam)(Yam,Cocoa)(Yam,Cocoa)
@(Appletizer,Cocoa)(Cocoa,Pawpaw)
@(Appletizer,Pawpaw)
@(R Grape,Sprite)(Sprite,Granadilla)(Sprite,Granadilla)(Sprite,Granadilla)(Sprite,Granadilla)(Sprite,Granadilla)(Sprite,Granadilla)
@(R Grape,Granadilla)(Granadilla,Strawbery)(Granadilla,Strawbery)(Granadilla,Strawbery)(Granadilla,Strawbery)(Granadilla,Strawbery)
@(R Grape,Strawbery)(Strawbery,Stone)(Strawbery,Stone)(Strawbery,Stone)(Strawbery,Stone)
@(R Grape,Stone)(Stone,Yam)(Stone,Yam)(Stone,Yam)
@(R Grape,Yam)(Yam,Cocoa)(Yam,Cocoa)
@(R Grape,Cocoa)(Cocoa,Pawpaw)
@(R Grape,Pawpaw)
@(Sprite,Granadilla)(Granadilla,Strawbery)(Granadilla,Strawbery)(Granadilla,Strawbery)(Granadilla,Strawbery)(Granadilla,Strawbery)
@(Sprite,Strawbery)(Strawbery,Stone)(Strawbery,Stone)(Strawbery,Stone)(Strawbery,Stone)
@(Sprite,Stone)(Stone,Yam)(Stone,Yam)(Stone,Yam)
@(Sprite,Yam)(Yam,Cocoa)(Yam,Cocoa)
@(Sprite,Cocoa)(Cocoa,Pawpaw)
@(Sprite,Pawpaw)
@(Granadilla,Strawbery)(Strawbery,Stone)(Strawbery,Stone)(Strawbery,Stone)(Strawbery,Stone)
@(Granadilla,Stone)(Stone,Yam)(Stone,Yam)(Stone,Yam)
@(Granadilla,Yam)(Yam,Cocoa)(Yam,Cocoa)
@(Granadilla,Cocoa)(Cocoa,Pawpaw)
@(Granadilla,Pawpaw)
@(Strawbery,Stone)(Stone,Yam)(Stone,Yam)(Stone,Yam)
@(Strawbery,Yam)(Yam,Cocoa)(Yam,Cocoa)
@(Strawbery,Cocoa)(Cocoa,Pawpaw)
@(Strawbery,Pawpaw)
@(Stone,Yam)(Yam,Cocoa)(Yam,Cocoa)
@(Stone,Cocoa)(Cocoa,Pawpaw)
@(Stone,Pawpaw)
@(Yam,Cocoa)(Cocoa,Pawpaw)
@(Yam,Pawpaw)
@(Cocoa,Pawpaw)Your program description makes no sense. What exactly is it supposed to do?
Your errors make no sense. What is it doing wrong?
Your program output makes no sense. Look up pre-order, in-order, and post-order notation for representing trees. Pick one of those that you think would be best. I would go with pre-order. Because what you are doing isn't understandable.
By the way, I think your concept of a tree is flawed. A node in a tree has 3 things. it has a reference to its parent, it has references to any of its children, and it has some key value that represents the node (if each node were represented by numbers, the value would be an integer or something). In the case of the root, its reference to its parent is null. I don't know what you are doing with your tree, but it is highly confusing. -
Hello to all the Apex champs out there, can you please help me with the following problem:
I have a table, and in its simplified version, it has the following rows:
Id Pid Description
1 NULL Id 1, Parent Id NULL
2 1 Id 2, Parent Id 1
3 2 Id 3, Parent Id 2
4 1 Id 4, Parent Id 1
5 4 Id 5, Parent Id 4
When these rows are displayed in a tree, the output is:
Id 1, Parent Id NULL
Id 2, Parent Id 1
Id 3, Parent Id 2
Id 4, Parent Id 1
Id 5, Parent Id 4
I am on a form page that already shows the record with id as 1 (and the tree root id as 1), and I need to display only the children for 1, i.e.
Id 2, Parent Id 1
Id 3, Parent Id 2
Id 4, Parent Id 1
Id 5, Parent Id 4
Is there a way by which I can suppress the first Parent Id record as I am already viewing the record on the page?
Many thanks in advance.
Regards,
DhruvaHi,
Your tree must contain a root node - that is, the top parent in the tree.
You can, however, hide this by replacing the contents of the tree's Parent Node Template with &nbsp; (you have to put something in the setting otherwise Apex will reset it to the default contents).
Andy -
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 -
Someone please help me Design the database of bill of materials with 1 item can have mutiple parent
I got this sample from Uri
Dimant (MCC, MVP) ,
The problem is i want 1 item to have multiple parent but this example don t let 1 item to have multiple parents. this is not suit for my objective.
CREATE TABLE Employees
empid int NOT NULL,
mgrid int NULL,
empname varchar(25) NOT NULL,
salary money NOT NULL,
CONSTRAINT PK_Employees PRIMARY KEY(empid),
CONSTRAINT FK_Employees_mgrid_empid
FOREIGN KEY(mgrid)
REFERENCES Employees(empid)
CREATE INDEX idx_nci_mgrid ON Employees(mgrid)
SET NOCOUNT ON
INSERT INTO Employees VALUES(1 , NULL, 'Nancy' , $10000.00)
INSERT INTO Employees VALUES(2 , 1 , 'Andrew' , $5000.00)
INSERT INTO Employees VALUES(3 , 1 , 'Janet' , $5000.00)
INSERT INTO Employees VALUES(4 , 1 , 'Margaret', $5000.00)
INSERT INTO Employees VALUES(5 , 2 , 'Steven' , $2500.00)
INSERT INTO Employees VALUES(6 , 2 , 'Michael' , $2500.00)
INSERT INTO Employees VALUES(7 , 3 , 'Robert' , $2500.00)
INSERT INTO Employees VALUES(8 , 3 , 'Laura' , $2500.00)
INSERT INTO Employees VALUES(9 , 3 , 'Ann' , $2500.00)
INSERT INTO Employees VALUES(10, 4 , 'Ina' , $2500.00)
INSERT INTO Employees VALUES(11, 7 , 'David' , $2000.00)
INSERT INTO Employees VALUES(12, 7 , 'Ron' , $2000.00)
INSERT INTO Employees VALUES(13, 7 , 'Dan' , $2000.00)
INSERT INTO Employees VALUES(14, 11 , 'James' , $1500.00)
WITH EmpCTE(empid, empname, mgrid, lvl)
AS
-- Anchor Member (AM)
SELECT empid, empname, mgrid, 0
FROM Employees
WHERE empid = 1
UNION ALL
-- Recursive Member (RM)
SELECT E.empid, E.empname, E.mgrid, M.lvl+1
FROM Employees AS E
JOIN EmpCTE AS M
ON E.mgrid = M.empid
SELECT * FROM EmpCTE
My object is
I want to design the database of bill of materials which contain item and amount.
So the amount of child will depend on amount of parent in term of ratio. For example
A(1) A(2)
| ----> |
B(2) B(4)
My problem is when i try to add the parent and child . Let A is the parent of B , If i try to add A to be the child of C
I want B to come along with A as well. For example
A C
| C ---> | For this I have to store the relation of all item in my list to check that this item have a child or not if yes
B
A The child must come along with its parent , What the Er-diagram should be for all of my requirement?
|
B
Base on the example that Uri
Dimant gave me , i have to stroe 1 item wtih multi parents for example if b is a child of a And b have c as child , When i insert D as a parent of B , c will automatic come along with B , But this not seem gonna work.
item Parent
A NULL
B A
C B
B D
Am i wrong to go this way , any ideathanks Uri
Dimant
I am
little confuse about how can i write
hierarchy sql from this relation , Thanks
so far i got
WITH EmpCTE(cid, cname, pid, lvl)
AS
SELECT cid , cname , children.pid , 0
FROM children INNER JOIN
parents ON children.pid = parents.pid
where cid = 1
UNION ALL
SELECT E.cid , E.cname , E.pid , M.lvl+1
FROM ( select cid , cname , children.pid FROM children INNER JOIN
parents ON children.pid = parents.pid) AS E JOIN EmpCTE AS M
ON E.pid = M.cid
SELECT * FROM EmpCTE -
Aggregation with a parent child hierarchy
Hi
I have 2 tables, hierarchy and data
hierarchy has 2 columns parent and child
data contains values for the lowest rungs of the hierarchy described.
What i'd like to do is, using the hierarchy described, sum the lowest rung values up to their parent values and so on.
Quick example:
Hierarchy
child parent
1 null
2 1
3 1
4 2
5 2
Data
hiearchyid value
3 10
4 20
5 30
output required
1 60
2 50
3 10
4 20
5 30
The last 3 rows are just the 2nd table so i can just union those in but how would i work out the first two values using sql... have tried combinations of connect by, analytics (partition by etc) and rollup but to no avail...
Any help would be appreciated..
Cheers
Alex@Aketi
It is One way that We derive
"sys_connect_by_path(RowIDToChar(RowID),'.') as
RowIDList"
Then
We use Left Join Using
"instr(RowIDList,RowIDToChar(RowID))".sorry, didn't catch what you mean.
my site :-)
http://oraclesqlpuzzle.hp.infoseek.co.jp/4-13.html
pity, I don't know Japanese :(
@Rob
your query is good and simple :) probably it's the best alternative for the OP.
But it won't work with not a plain hierarchy, e.g.:
1
2 3
4
5 6
SQL> create table hierarchy (child,parent)
2 as
3 select 1, null from dual union all
4 select 2, 1 from dual union all
5 select 3, 1 from dual union all
6 select 4, 3 from dual union all
7 select 4, 2 from dual union all
8 select 5, 4 from dual union all
9 select 6, 4 from dual
10 /
Table created
SQL>
SQL> create table data (hierarchyid,value)
2 as
3 select 5, 10 from dual union all
4 select 6, 25 from dual
5 /
Table created
SQL>
SQL> select h.child
2 , sum(connect_by_root d.value)
3 from hierarchy h
4 , data d
5 where h.child = d.hierarchyid (+)
6 connect by prior h.parent = h.child
7 group by h.child
8 order by h.child
9 /
CHILD SUM(CONNECT_BY_ROOTD.VALUE)
1 70
2 35
3 35
4 70
5 10
6 25
6 rows selected
SQL> -
Hi
I have a parent child ragged hisrarchy. I want to build level wise dimension to be able to report using crystal .
The PC table I have is like
Child Parent
A11 A1
A12 A1
A111 A11
A112 A11
A113 A11
A121 A12
A122 A12
A1121 A112
A1221 A122
A1222 A122
I want to solve this as a level based hierarchy using universe like:
LEV1 LEV2 LEV3 LEV4
A1 A12 A122 A1222
A1 A12 A122 A1221
A1 A11 A112 A1121
A1 A12 A122
A1 A12 A121
A1 A11 A113
A1 A11 A112
A1 A11 A111
A1 A12
A1 A11
Can somebody please put some light on this how can I achieve this?
Thanks
AtulHi Atul,
You can use a Derived Table that flatten the hierarchy.
Here is a sample based on the example you provided, you just have to replace "child", "parent" and "myTable" strings by the corrseponding column and table names:
SELECT DISTINCT
Z.child,
A.parent_1,
A.child_1,
A.parent_2,
A.child_2,
A.parent_3,
A.child_3,
Z.parent AS parent_4,
Z.child AS child_4
FROM myTable Z,
SELECT DISTINCT
A.parent_1,
A.child_1,
A.parent_2,
A.child_2,
Z.parent AS parent_3,
Z.child AS child_3
FROM myTable Z,
SELECT DISTINCT
A.parent_1,
A.child_1,
Z.parent AS parent_2,
Z.child AS child_2
FROM myTable Z,
SELECT DISTINCT
parent AS parent_1,
child AS child_1
FROM myTable
WHERE parent = 0 OR parent IS NULL
) A
WHERE A.child_1 = Z.parent
) A
WHERE A.child_2 = Z.parent
) A
WHERE A.child_3 = Z.parent
UNION
SELECT DISTINCT
A.child_3 AS child,
A.parent_1,
A.child_1,
A.parent_2,
A.child_2,
A.parent_3,
A.child_3,
NULL AS parent_4,
NULL AS child_4
FROM myTable Z,
SELECT DISTINCT
A.parent_1,
A.child_1,
A.parent_2,
A.child_2,
Z.parent AS parent_3,
Z.child AS child_3
FROM myTable Z,
SELECT DISTINCT
A.parent_1,
A.child_1,
Z.parent AS parent_2,
Z.child AS child_2
FROM myTable Z,
SELECT DISTINCT
parent AS parent_1,
child AS child_1
FROM myTable
WHERE parent = 0 OR parent IS NULL
) A
WHERE A.child_1 = Z.parent
) A
WHERE A.child_2 = Z.parent
) A
WHERE A.child_3 NOT IN (SELECT parent FROM myTable)
UNION
SELECT DISTINCT
A.child_2 AS child,
A.parent_1,
A.child_1,
A.parent_2,
A.child_2,
NULL AS parent_3,
NULL AS child_3,
NULL AS parent_4,
NULL AS child_4
FROM myTable Z,
SELECT DISTINCT
A.parent_1,
A.child_1,
Z.parent AS parent_2,
Z.child AS child_2
FROM myTable Z,
SELECT DISTINCT
parent AS parent_1,
child AS child_1
FROM myTable
WHERE parent = 0 OR parent IS NULL
) A
WHERE A.child_1 = Z.parent
) A
WHERE A.child_2 NOT IN (SELECT parent FROM myTable)
UNION
SELECT DISTINCT
A.child_1 AS child,
A.parent_1,
A.child_1,
NULL AS parent_2,
NULL AS child_2,
NULL AS parent_3,
NULL AS child_3,
NULL AS parent_4,
NULL AS child_4
FROM myTable Z,
SELECT DISTINCT
parent AS parent_1,
child AS child_1
FROM myTable
WHERE parent = 0 OR parent IS NULL
) A
WHERE A.child_1 NOT IN (SELECT parent FROM myTable)
Regards,
Didier -
Hi,
I have this table REQ_DETAILS
detail_id value_id parent
282 125 281
283 126 281
284 119 (null)
285 127 284
286 128 284
301 120 (null)
341 1169 321
303 130 301
322 1168 321
334 123 (null)
335 129 301
342 1170 321
321 122 (null)
361 1172 334
362 1171 334
363 119 (null)
364 120 (null)
365 1170 364
281 118 (null)
219 125 284
The column PARENT refers to DETAIL_ID.
and I've NUMTABLE of type INTEGER. (create or replace TYPE NUMTABLE AS TABLE OF INTEGER;)
I'd like to write a function which takes detail_id's as input and returns the correct order of the input. (parent-child format)
for example
order_req_det (detId_in NUMTABLE) return NUMTABLE;
order_req_det (219, 284, 285, 286, 282, 283, 281, 362, 334, 361)
should return the below output.
284
219
285
286
281
282
283
334
361
362
Any suggestions?
Regards.Guys, not even a suggestion?
SQL> desc numtable;
numtable TABLE OF NUMBER(38)
SQL> select * from test;
DETAIL_ID VALUE_ID PARENT
282 125 281
283 126 281
284 119
285 127 284
286 128 284
301 120
341 1169 321
303 130 301
322 1168 321
334 123
335 129 301
342 1170 321
321 122
361 1172 334
362 1171 334
363 119
364 120
365 1170 364
281 118
219 125 284
20 rows selected.
SQL> declare
2 vt1 numtable :=
3 numtable(219, 284, 285, 286, 282, 283, 281, 362, 334, 361);
4 vt2 numtable;
5 vt3 numtable;
6 vt4 numtable := numtable();
7 --v2 number;
8 begin
9 select detail_id
10 bulk collect into vt2
11 from test
12 where parent is null
13 and detail_id in( select column_value
14 from table(vt1));
15 for i in 1..vt2.count loop
16 select detail_id
17 bulk collect into vt3
18 from test
19 start with detail_id = vt2(i)
20 connect by prior detail_id = parent
21 order siblings by detail_id;
22 vt4 := vt4 multiset union vt3;
23 end loop;
24 for i in 1..vt4.count loop
25 dbms_output.put_line(vt4(i));
26 end loop;
27 end;
28 /
284
219
285
286
281
282
283
334
361
362
PL/SQL procedure successfully completed. -
Child.swf to pass two variables to parent in global function
Hi, I have a parent.swf and wish to load a varying child.swf as a sub-menu. How do I establish a global function that will allow the child.swf to pass back two variables (storyName & storyType) to the parent and kick off a task.
The submenu (swf) items will change so I cannot explicitly add a listener to a child.button. The submenu is on a children’s library so will have numerous graphics and movieclips included so I don’t think it would be suitable to simply call xml data to build a menu at runtime (at my level of knowledge). There will be a number of child.swf depending on books available.
I am not familiar with package { and public class { etc...
In as2 I would have used a _global.function() and used that to pass the variables back to the parent and then start a parent.action.
Totally new to AS3, suggestions appreciated. I have no problem loading the child.swf.Hi Ned, thank you for your response. I don’t know if it is relevant, but the container clip is run via AIR. That seems to affect some things as I’ve lost fullscreen functionality somewhere.
I tried you suggestions, if I have translated it into place correctly I don’t know. Do I need to treat the parent.parent as a variable (yes this one is done via a loader) ?
I get an error if I leave the function call open, I can tell I’m getting into the call as the trace on each side is happening.
In the External Movie:
blob_b.addEventListener(MouseEvent.CLICK, ms_bF);
function MbRemEL(nameof:String):void {
blob_b.removeEventListener(MouseEvent.CLICK, ms_bF);
function ms_bF(event:MouseEvent):void {
var m_ar:Array = new Array();
m_ar=event.target.name.split("_");
MbRemEL("r");
trace("StoryMenu: "+event.target.name);
if (this.parent.parent != null){
MovieClip(parent.parent).story = event.target.name;
//MovieClip(parent.parent).gcr(event.target.name);
// = TypeError: Error #1006: gcr is not a function.
MovieClip(parent.parent).gotoAndStop("g_home");
In Container Movie:
function gcr(stry:String):void{
trace("gcr: "+stry); -
When_window_closed can't determine the right parent
I have a problem that the when_window_closed can't determine the right parent in de qms$window.when_window_closed procedure of headstart.
In a form I have two windows. One is the parent window and one is a child window. After doing some changes in my parent window I navigate with a button (go_block) to this child window. When I want to close the child window, the child window thinks it's the last window and asks if I want to save my changes. If I say yes my changes are commited and if I say no both the parent and the child window are closed.
A detail about the child window is: the child window has no key_based_link to the blocks on the parent window. I have a similar form with two windows but in this form the blocks are connect by a key_based_link in that form the child window can determine the parent window and does not ask if it has to save any changes.
My question is: Does anyone know how my child window can determine the parent window, even though it's not connected with a key_based_link to the other block, so that when I close the child window I won't be asked to save any changes? In qms$window.when_window_closed the parent is determined but in this case it returns a null for it's parent.Some additional information, I checked the code of the when_window_closed
and I see the following:
-- this is part of the code in qms$window.when_window_closed who checks if the child window has a parent
if name_in('system.form_status') = 'CHANGED'
then
-- my parent form has been changed so the form_status is changed and I will enter this part of the code
l_group_id := find_group('CGSH$FORM_OBJECTS');
l_parent_id := find_column('CGSH$FORM_OBJECTS.PARENT_NAME');
l_child_id := find_column('CGSH$FORM_OBJECTS.OBJECT_NAME');
l_count := get_group_row_count(l_group_id);
for i in 1..l_count loop
l_child := get_group_char_cell(l_child_id, i);
if upper(l_child) = upper( get_view_property
( get_item_property
( name_in('system.trigger_item')
, item_canvas
, window_name
then
l_parent := get_group_char_cell(l_parent_id, i);
-- l_parent is null ????? Should be a value, cause it's a child window.
-- the only thing I can determine that de parent is null, is that the child window has
-- no key_based_link with the parent window.
l_last_window := (l_parent is null); -- l_last_window becomes true
exit;
end if;
end loop;
if l_last_window -- is true cause the parent id was null
then
if qms$errors.show_message('QMS-00158')
then -- do you want to commit the change
-- if yes then both my child and parent form are commited which I don't want yet
commit_form;
if name_in('system.form_status') <> 'QUERY'
then
go_block('QMS$TRANS_ERRORS');
raise form_trigger_failure;
end if;
else
-- if no then both my child and parrent form are closed and all the changes are discarded
exit_form(no_validate,full_rollback);
end if; -- show message
end if; -- last window
end if; -- form status 'changed'
How can the child window, have a parent window which is null?
And how can I resolve this problem? So that I have a parent window with a value? -
Update parent status based on all children status and sum of children amount.
Hi,
I need to write sql query for the following scenarios.
We have 3 financial systems (sys1, sys2, sys3) where a same transaction gets entered independently into each system OR entered into one and exported to the other system. Transaction need not be in all 3 systems.
We need to create reconcile report to see the status of transaction and display if it is reconciled or not. For this, in our stored procedure we are pulling data from 3 systems into temp tables and using CTE and other logic marking each transaction status
in each system temp table. One of the systems (eg sys1), we made it as source.
Sys1 temp table has both parent and child records and are distinguished using type. Sys2 and sys3 has only children records. When report is created, we are showing parent from sys1 temp table and
children from new temp table where children status is updated based on availability of it in all 3 systems.
DECLARE
@sys1 TABLE
ID int,
childID varchar(20),
ParentID varchar(20),
RecType decimal(3,0),
SettleDate smalldatetime,
Principal money,
Sys3ID varchar(16)
NULL,
Sys2ID int
NULL,
Status varchar(25) NULL
DECLARE
@sys2 TABLE
TxID int
PRIMARY KEY NOT
NULL,
CommonTransactionID varchar(16),
SettleDate smalldatetime,
Par money,
Sys3ID varchar(16) NULL,
Sys1ChildID,
Sys1ParentID bigint
DECLARE
@sys3 TABLE
Sys3ID varchar(16),
REFERENCE
varchar(16),
VALUE_DATE datetime,
DIRECTION char(1),
AMOUNT money,
RecSource varchar(2)
Insert Into @sys1 (ID, childID, ParentID, RecType, SettleDate, Principal)
Select 172876, 217955, 217954, 100, ‘2015-03-01’, 100.00
Union
Select 172877, 217956, 217955, 50, ‘2015-03-01’, 15.00
Union
Select 172878, 217957, 217955, 50, ‘2015-03-01’, 25.00
union
Select 172879, 217958, 217955, 50, ‘2015-03-01’, 10.00
Union
Select 172880, 217959, 217955, 50, ‘2015-03-01’, 10.00
union
Select 172881, 217960, 217955, 50, ‘2015-03-01’, 40.00
Insert Into @sys2(TxID, Sys1ID, settleDate, Par)
Select 4336620, 217956, ‘2015-03-01’, 15.00
Union
Select 4336621, 217957, ‘2015-03-01’, 25.00
union
Select 4336613, 217958, ‘2015-03-01’, 10.00
Union
Select 4336614, 217959, ‘2015-03-01’, 10.00
union
Select 4336615, 217960, ‘2015-03-01’, 40.00
Insert into @sys3(Sys3ID, Reference, Value_Date, Direction, Amount)
Select 1, ‘5654471 4336620’, ‘2015-03-01’, ‘O’, 15.00
Union
Select 2, ‘5654481 4336621’, ‘2015-03-01’, 'O',25.00
Union
Select 3, ‘5654491 4336613’, ‘2015-03-01’, 'O',10.00
Union
Select 4, ‘5654501 4336614’, ‘2015-03-01’, 'O',10.00
Union
Select 5, ‘5654511 4336615’, ‘2015-03-01’, 'O', 40.00
After going thru lot of other logic, final temp table will have only children with status assigned. The above temp table data is only for 1 scenario.
The following are status of children.
This is how status of children is determined:
Not Settled – All child records start as Not settled in temp tables.
Settled – when record exists in sys3 and other criteria is met.
Partially settled – record exists in sys3 and either in sys1 or sys2 or other criteria is not met.
Reconciled – child record should exist in all 3 systems and all criteria is match
Mismatched – record has wrong amount when compared in any of 2 systems.
**************** My Part below*******************
My part is to update the status of parent based on children status and parent amount must match sum of child amounts. If amounts don’t match, then leave the status of parent as null.
Determining the status of parent:
Not Settled – None of children has yet settled.
Settled – All children are settled.
Partially settled – some of children are as settled OR 1+ children are partially settled.
Reconciled – All children are reconciled.
Partially Reconciled – some children are partially reconciled.
Null – 1 or more childen has a status of mismatched.
AND sum of children amount should match parent amount
How can I update the status of parent based on all children and sum of amount of children equal to parent amount.
Thanks,
Spunny>> We have 3 financial systems (sys1, sys2, sys3) where the same transaction gets entered independently into each system OR entered into one and exported to the other system. Transaction need not be in all 3 systems. <<
Your design is fundamentally wrong. In RDBMS, we want to have one fact, one way, in one place in the schema. The goal of all databases is to remove redundancy, not increase it. This not just SQL; this was true for hierarchical and network databases before them!
>> We need to create reconcile report to see the status of transaction and display if it is reconciled or not. For this, in our stored procedure we are pulling data from 3 systems into temp tables and using CTE and other logic marking each transaction
status in each system temp table. One of the systems (eg sys1), we made it as source. <<
You have re-invent the worst of 1970's file processing, but you want to use a temp table instead of scratch tape. This is not RDBMS or good SQL.
>> Sys1 temp table has both parent [sic] and child [sic] records [sic] and are distinguished using type. Sys2 and sys3 has only children [sic] records [sic]. When report is created, we are showing parent from sys1 temp table and children from new temp
table where children [sic] status is updated based on availability of it in all 3 systems. <,
The terms “child” and “parent” are not part of RDBMS. They come from network databases. You are building fake pointer chains we do have referenced and referencing tables. Or do you mean to model weak and strong entities? Where is the DRI actions?
These things are not tables! They have no keys, so they are called (garbage) piles. But even the garbage is wrong. There is no generic “id” in RDBMS; it has to be “<something in particular>_id” to be valid. Since you do not do math on it, it should not
be a numeric.
A “rec_type” is a nominal scale, so it cannot be a numeric either! Likewise, we have no generic “status”, but a status is state of being so it has to have a temporal dimension. And did you know that “reference” is a reserved word in SQL as well as another ISO-11179
violation.
The MONEY data type does not do correct math. Google it! It is another Sybase left-over that nobody should ever use.
Finally, you used the old Sybase INSERT INTO ..SELECT..), .. disaster instead of the ANSI/ISO Standard VALUES table constructor.
>> This is how status of children [sic] is determined: ..
My part is to update the status of parent [sic] based on children [sic] status and parent [sic] amount must match sum of child [sic] amounts.<<
Your narrative describes what Tom Johnston called a Non-Normal Form Redundancy. We do not put summary data in the strong entity; another basic data modeling principle. We build a VIEW that gives us the current summary. Your mindset is still in punch cards and
magnetic tape files.
"No matter how far you have gone down the wrong road, turn around!" -- Turkish proverb.
Can you start over and do it right?
--CELKO-- Books in Celko Series for Morgan-Kaufmann Publishing: Analytics and OLAP in SQL / Data and Databases: Concepts in Practice Data / Measurements and Standards in SQL SQL for Smarties / SQL Programming Style / SQL Puzzles and Answers / Thinking
in Sets / Trees and Hierarchies in SQL -
Hello,
Although I've found way and scripts to parent mask vertices to objects, I've been unsuccessful if creating the reverse.
I'm fairly new at this but not new to programming.
What I would like my this script to achieve:
Making a layer mask at the corners of a layer - check
Creating 4 nulls - check
Parenting the nulls to the 4 corners -
For creating the mask I have this:
var myShape = new Shape();
var vertices = new Array ();
myShape.vertices = [[0,0], [0,100], [100,100], [100,0]];
var myProperty = theMaskGroup.property("ADBE Mask Shape");
var vertexLimit = myShape.vertices.length;
For creating the nulls:
function Nulls (){
for (var i = 0; i < vertexLimit; i++){
theNull = theComp.layers.addNull();
theNull.source.name = "Null"+(i+1);
i+1;
nulls[i] = theNull;
When it comes to moving/parenting nulls to mask verts I am completely lost.
Any help would be much appreciated.
Thank youHi chillywilson,
As far as I know, by default you can`t just parent any property to mask vertices.
But you can do it in two ways:
break mask vertices to Nulls and then parent anything to them.
This script has this function:
Add Ons - aw_Triangulator | VideoHive
There is also a plugin that represents mask vertices as effect properties:
http://aescripts.com/bao-mask-avenger/ -
Deleting parent entity of oneToMany does not delete children first,
I have two entities related with a bi-rdirectional OneToMany relationship. When I delete the parent, I want eclipseLink to automatically delete the child entities first before deleting the parent entity. I have implemented what I understand all the documents are telling me I should implement, but I can not get it working.
When I try and delete the parent I get an SQLException as the foreign key constraint has been violated as there are child records for the parent I am trying to delete. It was my understanding, that if you have all the annotations correct on my Entities, then all i have to do is delete the parent and eclipseLink will delete the children first and therefore i should never get the SQL exception.
Here is some snippets of my code.
Entities
@Entity(name = "PARENTS")
public class ParentEntity {
@Id
@Column(name = "PARENT_ID", nullable = false)
private String parentID;
@Column(name = "DISPLAY_NAME", nullable = false)
private String displayName;
@OneToMany(mappedBy="parent", orphanRemoval=true, cascade=CascadeType.ALL)
private Collection<ChildEntity> childEntities;
@Entity(name = "CHILDREN")
@IdClass(ChildIdentifier.class)
public class ChildEntity {
@Id
@Column(name="ITEM_ID", nullable=false)
private String itemID;
@Id
@ManyToOne()
@JoinColumn(name="PARENT_ID", nullable=false)
private ParentEntity parent;
public class ChildIdentifier implements Serializable {
private String itemID;
private String parent;
Tables created from these entities
PARENTS
Name Null? Type
PARENT_ID NOT NULL VARCHAR2(36)
DISPLAY_NAME NOT NULL VARCHAR2(255)
PrimaryKey = PARENT_ID
CHILDREN
Name Null? Type
ITEM_ID NOT NULL VARCHAR2(36)
PARENT_ID NOT NULL VARCHAR2(255)
PrimaryKey = ITEM_ID,PARENT_ID
ForeignKey = PARENTID = PARENTS.PARENT_ID
Code to delete a parent
public void deleteParent(String id)
ParentEntity e= em.find(ParentEntity .class, id);
if (e!= null)
em.remove(e);
Exception seen
javax.persistence.RollbackException: Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.4.0.v20120119-r10715): org.eclipse.persistence.exceptions.DatabaseException
Internal Exception: java.sql.SQLIntegrityConstraintViolationException: ORA-02292: integrity constraint (MYSCHEMA.CHILDREN_FK_P_PARENTS) violated - child record found
Error Code: 2292
Call: DELETE FROM PARENTS WHERE (PARENT_ID = ?)
I have added eclipse logging entries in my persistence.xml to try and see what is going on
<property name="eclipselink.logging.level" value="FINE"/>
<property name="eclipselink.logging.parameters" value="true"/>
And in my jdev console when running my test, i do not see any queries of CHILDREN before it tries to delete from PARENTS.
Am I missing something really obvious?
Thanks in advance.
Edited by: smaslin on Feb 20, 2012 9:20 AM
Edited by: smaslin on Feb 21, 2012 5:26 AM"optional=false" only affects DDL generation, not runtime JPA behavior. PrivateOwned is similar to orphanRemoval in that it should cause the removal of child entities when they are dereferenced from the parent (ie remove them from the parent's collection). Cascade remove or cascade all should be all you need, but PrivateOwned+orphanRemoval should still cause the collection to be removed, as long as there are entities within the Parent's list of children to remove.
The only case where I can see this not occuring is if you have not been maintaining the bidirectional relationship. That is, if you have added Child entities and set a parent, but not updated the Parent's collection of children to reflect that change. A simple test is to refresh the parent before removal - call em.refresh(e); right before the em.remove(e);. If this works, then you will need to change your application so that when you add parents to a child you also add the child to the parent's list of children - JPA does not maintain relationships for you and not doing so will keep the cache inconsistent with what is in the database.
Best Regards,
Chris
Maybe you are looking for
-
New iMac 24" Grey - Energy Saver Issue
10.4.10 2.4Ghz Intel Core 2 Duo 1GB 667 Mhz DD2 SDRAM Boot Rom 1M71.007A.B00 Model Ident: iMac7,1 *The Energy Saver is having issues* Put the Computer to sleep when it is inactive for - set to Never Put the display to sleep when it is inactive for -
-
Portal Commerce Templates in WLP 8.1?
Hi; Just having a first look around the new WebLogic Platform 8.1, I wanted to understand the strategy for developing and deploying e-Commerce websites. It seems clear that it should be possible to host an existing WebLogic Portal 7 SP2 e-Commerce te
-
Can someone tell me what is backed up in the DRS recovery for CUIC? Are: 1 Custom Reports 2 changes to stock reports? 3. Report Definitions? 4 Value Lists 5 Partner created custom reports? 6 Data Sources? 7 All Passwords? 8 Schedules? 9 Dashboards? a
-
Connecting to win xp pro from macbook
i have talked to apple care via phone and the geniuses at the local apple store and am hoping someone on the boards can help. i have a new macbook and a winxp pro machine. i can connect to the mac folders in my network places on the windows xp machin
-
I got my Droid Razr M a couple months back. After the Jelly Bean update I notice that I do not get sound when I am calling/talking over the phone. No ringing, no audio, nothing. However, people on the other end of the line can hear me. I then tr