# Jeff Haynes

Greenhorn
since Nov 09, 2004
Cows and Likes
Cows
0
In last 30 days
0
Total given
0
Likes
0
0
Total given
0
Given in last 30 days
0
Scavenger Hunt
Ranch Hand Scavenger Hunt
Greenhorn Scavenger Hunt

## Recent posts by Jeff Haynes

The reason why I ask this, is because on page 424 of the book there is a nice little diagram that shows what I thought was the same scenario.

<ejb-relationship-role-name>MovieBean</ejb-relationship-role-name>
<multiplicity>One</multiplicity>

<ejb-relationship-role-name>Trailer</ejb-relationship-role-name>
<multiplicity>One</multiplicity>

M1->TA
M2->TB

m1.setTrailer(M2.getTrailer())

Then you have this..

M1->TB

TA->null

M2->null

Maybe I am assuming to much here..

All thoughts are welcome!!

-Jeff
13 years ago
Okay tell me if I am wrong..

It is a 1-1 relationship between Foo and Bar

And

It is a 1-1 relationship between Bar and Foo

Given the information

F1->b1
F2->b2

And when you assign F2.setbar(f1.getBar())

Then this makes some sense as

F1->Null
F2->b1

Then shouldn't B2->Null be true too? Or is this answer wrong because you can't assume this?
13 years ago
I am a little confused on the answer to the following question from this book.

Given the container-managed unidirectional relationship:

Foo (0-1) -> Bar (0-1)

And the object relations:

f1->b1
f2->b2

What will be true after the following code runs?

f2.setBar(f1.getBar());

a.) f1.getBar() == null
b.) b2.getFoo() == null
c.) b1.getBar() == null
e.) none of the above

Here is my thought process:

I understand this to mean..

Foo (0-1) -> Bar (0-1)

For Foo, it can have zero or 1 bar.
For each Bar, it can have zero or 1 foos.

AKA here is my table structure.

FOO TABLE
Foo PK, Foo Num, Bar PK (can be null)

Bar Table
Bar PK, Bar Num, Foo PK (can be null)

I understand this to mean..

f1->b1
f2->b2

F1 has a bar(called 1)
F2 has a bar(called 2)

So if this code is called
f2.setBar(f1.getBar());

You will have

F1 has a bar(called 1)
F2 has a bar(called 1)

What I am missing is where does it say that each bar has a foo?

The answer by the way is A

I think I just don't understand the syntax of the question. Any ideas on how I should read this?
13 years ago
Again I am glad you passed!! The more the Certified Developers community grows the better. I can safely say for some unexplained reason I checked within my code if the record had been deleted before I read on this site that was a major cause of the 44/80 locking mark. It must of been a passing moment of brilliance on my part! Though after writting that code, then reading comments on this site, a bit of doubt raced through my head and I was forced to recheck what I had written.
14 years ago
I am glad you passed!! Congratulations!!

One question on your locking approach though.

When in the locking method, after you have waited for a notification that you may obtain the lock on the object, did you check to see if the record that your trying to obtain the lock on has been deleted?
14 years ago
And for the instance where they choose FileHandler I force them to choose a location for the log file.

-Jeff
14 years ago
Saheed,

I allow them to specify the level of logging, and the type of logging (FileHandler,ConsoleHandler) on the setup dialog.

-Jeff
14 years ago
Jon,

Here is what I do in the scenario you mentioned.

User A performs a search that retuns room Z and shows it as bookable
User B performs the same search
User A books room Z
User B attempts to book room Z

Basically what I do is inform the user(B) that the record has already been booked, and it is no longer bookable, and I perform the same search they have already done. This displays all records matching the criteria, including the one they were just trying to book with all customer values associated to the given records. I am basically making the assumption that the user won't be 'freaked out' by the change in data.. but will understand that there could potentially be many users working on the system at the same time thus causing the scenerio you mentioned.

-Jeff
14 years ago
Here is my take on caching.

You may decide to NOT cache the database file. Which means every time you want to return a result set, or update a record in the database file, you must then access the file.

Which in the real world is not applicable because of a likely performance degradation, due to the potential number of times one would have to re-read the file. However no where in the assignment does it say that Performance is something you MUST consider when designing your approach.

Though I would suggest that if you take this approach make it clear in your choices.txt file, and reference your reasons for doing so.

The second option is a bit more real world in that you do implement cacheing. IMHO this is a bit more complicated but not so much that you would risk failing the assignment due to an overwhelming amount of extra code that could lead to errors.

I have chosen the second approach and have documented why in my choices.txt file. I take the approach of maintaining a date-time for the last time the data file was updated. I keep this date in my Data class as a private member variable, and update it on initial read as well as every time I write to the file. In my case I write to the file every time an update occurs to any record. When a read action occurs, say a search, I check to see if the date on the file has changed, and if it has, rebuild my internal data array.

I don't worry so much about File Access Collision because as the directions say only one app will be accessing the file at any given time.

Hope that helps.

14 years ago
IMHO - if the directions say that the data is in a particular format(DataInputStream,DataOutputStream) then you aren't necessarily required to use these Classes. You simply need to make sure that when you write the data out to the file its in the same format.

14 years ago
In the URLyBird assignment the DBAccess interface has a method deleteRecord in which the comments describe it as deleting the record, and making the record number and associated disk storage available for reuse.

Which seems to imply that deleted records are never written back to the database file?

However the database file is defined to specify a deleted flag.

Thinking over this, what it seems to imply is that when a record is deleted, this doesn't actually remove the record from whatever structure you have loaded your records into but sets a delete flag. Then when a new record is added to the database, it is placed into the first deleted records space that is returned from your structure.

Is this how these directions are understood by most?

Thanks!
14 years ago