John Summers

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

Recent posts by John Summers

Steve,

Thanks for your reply, very concise and clear.

I think this subtlety is missed by a lot of developers as they would erroneously assume that only a thread blocking in wait() would acquire the lock. I guess using synchronized blocks or java.util.concurrent explicit Lock objects would make the syntax less error prone.

Many thanks
John
H JavaRanch,
First post in a long while...
I'd like to know: do Threads blocking on a synchronized method qualify for competing for the monitor in the same way as threads already in the object's wait set?
To make it clearer consider this tiny class:


At our current state of play we have C1 which is the lucky thread with the monitor and it's in the get() method at point X. Thread C2 is blocked on the get method as it can't get the monitor. Threads P1 and P2 have previously gone into the put() method and are now idling in the wait set. Now assume C1 trundles on and calls notify(). Is it possible that the notify call does not wake-up P1 and P2 but in fact the JVM picks C2 to acquire the monitor. It seems to me that it is, as they are all going to compete for the same monitor, however C2 is not technically 'in the wait set', it's blocking, and all the documentation seems to just talk about picking a thread in the wait set and waking it up.

Cheers,
John
Solved!!

Silly me.. I forgot to add

@JoinColumn(name="boringEntityId")

beside the @OneToOne tag.If you don't put @JoinColumn then HB use the default name which is boringEntity_boringCode. No @AssociationOverride required.

Regards,
John
Hello chaps,

I am writing some small hibernate examples and the simple @AttributeOverride is 'doing my head in' (as we say in the UK). The code below gives the error
Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Unknown column 'boringEntity_boringCode' in 'field list'
and I'm pretty sure this is because I'm using the @AttributeOverride wrong so hibernate is using the default name for the FK reference for BoringEntity, which won't work. Take a look:





And the tables are:

1_CompoundIdEntity2
-someCode
-boringEntityId

1_BoringEntity
-boringCode
-boringDesc

Any help appreciated. I don't find the documentation for this tag particularly revealing I'm afraid.
Cheers,
John
I have achieved this feat once. It wasn't easy.

Just mail them and be prepared for some bureaucracy.
ok i updated the FAQ.

Sun Training UK were pretty helpful. They said anyone with queries can contact them on:

[email protected]

But please read the FAQ first before emailing them moron questions.

j
right...

so this is nothing to do with the "static imports" feature. What I've done is just a plain old import..

So in summary if you do an import

import com.javaranch.Outer.Inner;

then you CAN use the shorthand syntax of Inner i = new Inner(); and you don't have to use Outer.Inner i = new Outer.Inner();

So ultimately any question which says you have to use Outer.Inner is wrong. You don't! You can import as above and use the shorthand syntax.

Which means my original first post was correct... you can use the longhand if you want to but if you import you can use the shorthand.

Thanks
john
I see the import statement but this looks like a plain old import statement to me. Don't static imports have the 'static' keyword?
Guys,

Thanks for the replies. Nidhi.. I think you are wrong. The whole point of a static inner class is that it is a top level class, it just happens to be defined within another classes definition. You do NOT have to use the Outer.Inner syntax. Please check the attached screenshot. You DO have to use this syntax for an inner class (i.e. one without the 'static' modifier).

However, if you are perverse you can, if you wish, use the Outer.Inner syntax to instantiate a static nested class. It is unneccessary but you can use it. Which brings me onto the whole point of my original post i.e. the original K+B question was a trick question.

John
Hi guys,

I have a quick syntax question about static nested inner classes. It's regarding K&B SCJP 6 pp.692.

Basically the question says:

"Which are true about a static nested class?" and option D is "If the outer class is named MyOuter, and the nested class is named MyInner, it can be instantiated using new MyOuter.MyInner();"

I just want to check this is a trick question. First off even though option D says "the nested class" they already said "true about a static nested class". Bearing this in mind then my understanding is that yes, this is correct, it CAN be instantiated this way, but in fact you don't have to put the "MyOuter" bit on for compilation to succeed.

I have this in one java file:


public class Outer {
static class Inner{}
}


And this in the main method in another class file:


Inner i2 = new Outer.Inner();//the longhand way, like the exam answer
Inner i = new Inner();//the shorthand way. this compiles fine!!



And it all compiles fine. So you don't HAVE to use new MyOuter.MyInner();

John
maybe this thread should be pinned near the top while the list is being compiled?
I have emailed Sun UK Training department to ask the 2 most critical questions and will post their response.

John
page 409 question 15
a)says "at line 4" and should say "at line 2".
b)in option E I think it should say "line 4" not "line 6"
Hi SCJPers,

I'm studying for either the full or upgrade SCJP6 exam and have not decided which one to do yet. The first thing I did was check the FAQ but it just gives the bare bones advice. After some use of the search facility I see this question is asked a lot. So can I tentatively suggest the SCJP FAQ is expanded a bit with the following issues or answers to them?.....

Key Points:
-should mention upgrade exam has less questions and a lower pass % mark
-say I have SCJP 1.4, can I do the 6 upgrade or do I need to do the full 6 exam?
-does the 6 upgrade cover a) solely the differences between 6 and 5 or b) can it test you on ANY feature of Java 6

Additional points... more 'subjective' but commonly asked:
-so is the upgrade "easier"?
-say you have the 1.4 SCJP... you want to learn Java 6 as deep as possible and be tested as hard as possible... would taking the full exam make you have to study harder (and thus "get more value from the process") than just doing the upgrade?

Cheers,
John
We could always just start posting "doubts" into this thread thus forcing K/B to start the official "verified errata" thread...

I needs my errata!