Vladimir Kroupa

+ Follow
since Dec 26, 2008
Cows and Likes
Total received
In last 30 days
Total given
Total received
Received in last 30 days
Total given
Given in last 30 days
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Vladimir Kroupa

Hello Eric and Elisabeth!
I have two questions for you:
1) How does the new book differ from Head First JavaScript?
2) Is the book compatible with the book JavaScript: The Good Parts? Do you agree with the author of this book on the parts of JavaScript that should be avoided?

Well, by "success message" I mean a message that informs the user that the requested action (e.g. creating a new record) has been performed successfully.
9 years ago
Spring MVC has great support for error messages. It would be nice to have similar feature for displaying success or information messages.
There has been an unresolved issue on this in Spring JIRA for quite some time, but it doesn't have as many posts as I would expect. Perhaps there is an easy solution for displaying localized messages that I am unaware of?

9 years ago

WHOIS information for itcertify4less.com :

Domain name: itcertify4less.com

Registrant Contact:
Murthy Medisetti ()

Administrative Contact:
Murthy Medisetti (murthy.medisetti@gmail.com)

9 years ago
Please stop promoting your own business. It is rather obvious.

Murty Medisetti wrote:You can buy from www.itcertify4less.com for very less price. One of my friends bought it for $175.00

9 years ago
The null reference can always be cast to any reference type (according to JLS3).
That makes it legal to pass the null refrerence as an argument to the method x.

The other question is - of the two overloaded methods, why is method B chosen?
When more than one applicable method is available, Java chooses the most specific method.

Quoting JLS3:

If more than one member method is both accessible and applicable to a method invocation, it is necessary to choose one to provide the descriptor for the run-time method dispatch. The Java programming language uses the rule that the most specific method is chosen.

The informal intuition is that one method is more specific than another if any invocation handled by the first method could be passed on to the other one without a compile-time type error.

So in your example, invocation of method x(B b) could also be handled by method x(A a) (B is a subtype of A, so it can be upcast to A) .
On the other hand, invocation of method x(A a) cannot be handled by method x(B b) (you cannot pass instance of A to a method that expects it subtype, B. Imagine passing an instance of Object to a method that takes a String - not legal).
That makes method x(B b) the more specific of the two.
Hi Adolfo,
Java allows implicit narrowing of primitive types for assignments, but not for method (or constructor) invocations.

The first statement is an assignment expression. According to JLS:

5.2 Assignment Conversion
In addition, if the expression is a constant expression (§15.28) of type byte, short, char or int :
* A narrowing primitive conversion may be used if the type of the variable is byte, short, or char, and the value of the constant expression is representable in the type of the variable.

On the right side of your assignment is an int literal (10), which is a constant expression. Its value (10) is representable in char type on the left side, so the requirements for implicit narrowing are met.

This time, a method (constructor) invocation conversion would take places, but narrowing conversion is not allowed for method invocation.

Quoting JLS:

5.3 Method Invocation Conversion
Method invocation conversions specifically do not include the implicit narrowing of integer constants which is part of assignment conversion (§5.2).

There is one more question from K&B Practice Exams book that I found hard to answer.
It is question 56 from Practice Exam 1:

Final class Items implements no interfaces and has one constructor:
Items( String name, int value )
And given that you want to make collections of Items objects and sort them (using classes and interfaces in java.lang or java.util), sometimes by name, and sometimes by value, which are true? (Choose all that apply.)

Among the possible answers are these two:
A. It's likely that you'll use the Arrays class.
B. It's likely that you'll use the Collections class.

The answer B is correct, but A is not. Why is that?

It is possible to achieve the required functionality with both Collections and Arrays utility classes. Since the term "collections" is overloaded (see K&B SCJP page 558), it is impossible to tell from the sentence (And given that you want to make collections of Items objects) that I shouldn't use array to hold the Items.

Yes, using Collections API is almost always preferable to using arrays, but I'm not sure that alone is enough to rule out the answer A.
I stumbled upon a question in K&B OCPJP Practice Exams book that confused me.
It's question 54 from Practice Exam 1.

I don't want to post the full question here, so I made a class diagram of the classes and their relationships instead.

The book states that following answers are true:

Glanks have a Bostron.
Jookers have a String.

Bostrons have a Bostron.

The last one is simple. But I don't get the first two. These would imply that Has-a relationship is transitive, is that really true?
I know that Is-A relationship is transitive (e.g. Glank is a Protefor), but composition (Has-a)?
If you would like to see the problem for yourself, you can checkout my Maven project from http://my-svn.assembla.com/svn/kroupv1/football. I'm using hsqldb and Maven Jetty plugin, so you won't have to configure anything. Just use the jetty:run goal.
If you are using an OS that doesn't have the /tmp directory, you might want to change the DataSource url property in the dao.xml Spring configuration file.

Thanks to anyone who donates his time!
I can now confirm that this is not Hibernate specific. I tried swapping Hibernate for OpenJPA. The insert statement generated when trying to persist the MatchEntity has the same problem:

It has to be a problem with JPA mapping. But it still don't see where
I'm using JPA with Hibernate 3.5.6 as the persistence provider. I've mapped some entities using JPA annotations and I'm using database schema generated by Hibernate, but I'm encountering incorrect SQL insert statements in runtime when trying to persist on of the entities.
Here are the entitites:

The Player entity looks like this:

The schema generated by Hibernate looks like this:

When I try to persist the MatchEntity, one of the generated insert statements is incorrect. Table Game_Player has three columns, not two.

Does anyone have an idea what could be wrong? I don't think that the interface types are causing the problems, I have the target entities specified and I tried to get rid of the interface types and the problem didn't go away.
I'll be grateful for any tips.
Well, it looks like that position is a reserved SQL keyword. Who would have thought that...
I'm stuck on this problem and I'd like to ask you guys for help. I'm having trouble mapping an Enumeration using JPA annotations.
I'm using Hibernate 3.5.6 as a persistence provider and I'm also using Spring ORM (version 3.0.4).
One of my entities has an enum field. This entity doesn't get a corresponding table generated.

I'm getting following errors:

If I remove the enumeration field, then Hibernate creates the table for this entity without problems.
Here is the entity class:

The class for this enumeration looks like this:

Does anyone have any ideas? I just can't see what's wrong with the mapping. Without the Position enum, everything works OK.
I was able to bind the map in a way that works for displaying the map values in a form (GET). However, the binding doesn't work when I try to submit the form.

When I try to submit, I get NullValueInNestedPathException: Invalid property 'cartMap[163840]' of bean class [shop.web.COs.ShoppingCartCO]: Value of nested property 'cartMap[163840]' is null.
But when I try to access the cartMap[163840] entry directly in JSP, it works.

This is what my JSP file looks like:

The controller code should be OK:

I'll be grateful for any tips. I have a book on Spring and I've searched the documentation, but I haven't find anything that would help.
10 years ago