Prosenjit Banerjee wrote:
I have understood the rule. But what can be the motivation behind it? I mean, if there is a possibility of some data to be lost if the programmer is not very careful, does not that go against the motto of Java?
Dave Tolls wrote:Looking at that page in Google Books I assume it's the units it's using.
The other examples given have a timing variable ending in _secs, a cache size ending in _mb and a download throttle ending in _kbps.
I will say I disagree with the whole underscore thing.
What's wrong with delaySeconds?
And I also dislike picking out instance variables by things like sticking an underscore at the start.
Henry Wong wrote:
Well, since you are already looking at the source code, look a bit further down, at the writeObject() and readObject() methods respectively. These are the methods that serializes and deserializes the HashSet.
Notice that these methods call the default methods -- which will serialize/deserialize everything but not the static or transient fields. Then, later in the methods, the map is serialized/deserialized by the methods.
Henry Wong wrote:
Keep in mind, that "transient" does *not* mean that it will not be serialized. Marking something as transient just means that the default mechanism does not serialize the field. In this case, the map is still serialized, the developer of the HashSet class just chose to serialize it differently.
Again, just test it. You will see that serializing and deserializing a hashset work fine.
Henry Wong wrote:The reason the underlying map is transient is because the developers chose to serialize the elements of the map with the readObject() and writeObject() methods. Perhaps, it is more efficient to do so, instead of letting the default implementation do it?
Regardless, have you tried it? If so, you will see that it works. The elements do get serialized and deserialized.
Dave Tolls wrote:Using a criteria may be the key point, but until you can figure out the SQL you would right outside of a Criteria you won't get very far.
So (assuming K. Holgate's query is correct, which is something you'd need to test) you would be looking at a Subquery method, probably the eq() one.
Dave Tolls wrote:What is the ORDER BY which defines what row is 'first'?
Roel De Nijs wrote:And what's the expected output if you have a 5th record like:
id name value group
5 a3 1 a
K. Holgate wrote:
You could do this with a self-join if you prefer.