This week's book giveaway is in the Programmer Certification forum.
We're giving away four copies of OCP Oracle Certified Professional Java SE 21 Developer Study Guide: Exam 1Z0-830 and have Jeanne Boyarsky & Scott Selikoff on-line!
See this thread for details.

Max Vandenburg

Ranch Hand
+ Follow
since Mar 09, 2006
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by Max Vandenburg

from UseCaseTaskEntity as en where en.useCaseEntity.iterationEntity.IterationID = iterID"
+ " and en.OwnerEntity.ProjectActorID in ( actorIdArr)";



SELECT o FROM Entity o
WHERE o.attribute1 = :id
AND o.attribute2 IN (:setOfAttributes)
Have a look here...
JSR220


2.1.8.5.1 Unidirectional OneToMany Relationships
The following mapping defaults apply:
Entity A is mapped to a table named A.
Entity B is mapped to a table named B.
There is a join table that is named A_B (owner name first). This join table has two foreign key
columns. One foreign key column refers to table A and has the same type as the primary key of
table A. The name of this foreign key column is formed as the concatenation of the following:
the name of entity A; "_"; the name of the primary key column in table A. The other foreign
key column refers to table B and has the same type as the primary key of table B and there is a
unique key constraint on it. The name of this foreign key column is formed as the concatenation
of the following: the name of the relationship property or field of entity A; "_"; the name
of the primary key column in table B.
Example:
@Entity
public class Employee {
private Collection<AnnualReview> annualReviews;
@OneToMany
public Collection<AnnualReview> getAnnualReviews() {
return annualReviews;
}
public void setAnnualReviews(Collection<AnnualReview> annualReviews)
{
this.annualReviews = annualReviews;
}
...
}
@Entity
public class AnnualReview {
...
}
In this example:
Requirements on the Entity Class Enterprise JavaBeans 3.0, Final Release Entities
33 5/2/06
Sun Microsystems, Inc.
Entity Employee references a collection of Entity AnnualReview.
Entity AnnualReview does not reference Entity Employee.
Entity Employee is the owner of the relationship.
The following mapping defaults apply:
Entity Employee is mapped to a table named EMPLOYEE.
Entity AnnualReview is mapped to a table named ANNUALREVIEW.
There is a join table that is named EMPLOYEE_ANNUALREVIEW (owner name first). This
join table has two foreign key columns. One foreign key column refers to table EMPLOYEE
and has the same type as the primary key of EMPLOYEE. This foreign key column is named
EMPLOYEE_<PK of EMPLOYEE>, where <PK of EMPLOYEE> denotes the name of the primary
key column of table EMPLOYEE. The other foreign key column refers to table ANNUALREVIEW
and has the same type as the primary key of ANNUALREVIEW. This foreign key
column is named ANNUALREVIEWS_<PK of ANNUALREVIEW>, where <PK of ANNUALREVIEW>
denotes the name of the primary key column of table ANNUALREVIEW. There
is a unique key constraint on the foreign key that refers to table ANNUALREVIEW.
No. Here is the output from again



here A has 3 next neighbours that is B Z and E
and A has a/belongs to 3 tracks 1, 2, and 3

and we are given a route from A - B - C - D

so from A we are only interested with B (dont care about Z & E)
then we look at the what track A has and we also look at what track B has...
in this case track 1 is a match...

so then we do a next matching

B neighbour is A and C. A is already been visited... so we only care about C... see for macthing line and between B and C which is 1... and so on...
18 years ago
I have an algorithm problem with recursion:

i have a route from A to D and it looks like this



the alphabet in the above list is an object of a class, lets call that class Nodes

each of this Nodes object they have some attributes... these are of type set..

the first set will store a bunch of other Nodes (these represent the current nodes neighbour)
the second set will store a bunch of tracks (Integer object representing what tracks the current nodes belong to)

(... bare with me here... )

so now i write up some code that initialise all the nodes... and here is the output...



and here is the code: (i removed the System.out... to shorten the code..)



what i want to do is to come up with some recursive algorithm so that it would print out something like this...

so i've come up with a pseudo code...


i've also come up with an actuall code but for some reason it'll only prints out the first step...

the code for this to follow...
18 years ago
say i have a Map, a HashMap

and its key is a bunch of Integer and the values is a List of strings. i.e.


then i have a Set that stores a list and it looks like this:



from the above set we can see that in the first list is ["A", "B", "C", "D", "F", "G" ]

and this list belongs matchest the value in the map with the key 1 and 3.

for the second list in the set ["A", "B", "E", "D", "F", "G"], this list matchest the value in the map with the key 2 and 3

i've built up a rough code to build the map and the setOfList, see code,



anyone can help me solve this,

thanks
[ October 03, 2006: Message edited by: Firman Drage ]
18 years ago
Ok its solved again... here
18 years ago
I modified the code(here) slightly so it compiles with 1.4 (without the generics)
and i also havent come accross the

Arrays.asList

method so i rebuild the graphI'm sticking to what i know for now. so now the code looks like this...




and the output i get is null pointer exception...
why is that?


[ October 02, 2006: Message edited by: Firman Drage ]
18 years ago
not really... someone mentioned something about recursion method... im not familiar with this
18 years ago
Hi guys,

I have a HashMap, and it stored a bunch of Strings... the key is a String and the value is a Set of String...

and it looks something like this

{ D=[E,C], C=[B], E=[B], B=[A] }

what is the best way to iterate through this map so i get the two list. i.e.

D-E-B-A and the other would be D-C-B-A
18 years ago
I have the following class as a example to a similar problem im having ...

Class Car


Class CreateCarFromList


in the last class i have an arraylist,carNames, with the following value
["Red", "Blue", "Yellow"]

than i do an iteration and create an instance of an object in each iteration and add it to another arraylist, carObject

my problem is what do i need to do, to add to the Car class or perhaps to CreateCarFromList Class.

so that i can say for a

String s = "Red";

give me from carObject list the Car object that has that attribute. (hope this make sense)
18 years ago
:roll: forget the above ... i think i found out why... thanks anyway
18 years ago
Code Snippet:


the code above loops through a map and prints out a list of Station. i.e.


depending on a map given, i sometimes get a duplicate station, i.e. "Finchley" would be printed twice somewhere in the list... so to make a unique list
i decided to use HashSet and use its add method to add all the element to the set.

Say i declare a HashSet someSet as an instance member right at the top of my code...

then in the code given i replace //HERE with someSet.add(s);

this compiles fine but when executed it causes my code to throw NullPointerException any idea why this is happening? and the compliler say that the exception is caused by the line someSet.add(s);

thanks
[ September 25, 2006: Message edited by: Firman Drage ]
18 years ago
thanks to all the guys here that helps me clear my doubts in some of the Exam objectives...

i did the exam today and now im off to the pub... cheers everyone
18 years ago
(correct me if im wrong)

GC will guarantee to call the finallize method once and only once on on that particular object which the GC attempts to delete.

but the GC it self is not guarantee to run... so the finalize method itself may never run.
[ September 08, 2006: Message edited by: Firman Drage ]
I just did the free exam in the JCHQ for 1.4, for the first time, and got 86%...

can one say that this is a good indication to what one will get for when doing it for real. Im taking the exam on the 18th, so one more week of cramming for me