Bram Pramono

+ Follow
since Feb 19, 2009
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 Bram Pramono

Hi all,

Does anyone here have experience with JPA/DB2 mapping?

I have tried many things but I cannot get it work properly. I am working with JPA and DB2 database for AS400.

Below are the 2 my mapping files possibilities I have tried:
- Mapping 1: using sequence

- Error from Mapping 1 :
* org.hibernate.exception.SQLGrammarException: could not get next sequence value
* java.sql.SQLException: [SQL0029] INTO clause missing from embedded statement.

- Mapping 2 : using Identity

- Error from Mapping 2:
* util.JDBCExceptionReporter [SQL0798] Value cannot be specified for GENERATED ALWAYS column ID.
* org.hibernate.util.JDBCExceptionReporter - [SQL0798] Value cannot be specified for GENERATED ALWAYS column ID.

My question is has anyone worked with JPA / DB2? If you do, how did you configure your database table and jpa? Did you use sequence or identity?

Please help.

Thank you in advance.


Hi guys,

This is a thing I'm very curious about. I just had a discussion with Roel and K.Tsang (link) about should threads trying to lock a locked record wait? or get an error message mentioning that a record is lock, please try again later? I feel that with my assignment and solution, error message seems to be good, but Roel and K say otherwise.

So please for people who did passed SCJD without using wait on lock, let me know. Thank you.


Hi Roel,

thanks for the reply. I have read the forum thread about Laura failing the exam. But she said that she didn't understand the statement of "no CPU cycle consumed", so I assumed that she did not write on her decision.txt about this problem. I, on the other hand, am 100% aware of the situation. I can explain why I took this decision. Is it that bad that a must requirement is not implemented, even if i can explain the specific reason?

Also my locking mechanisme assignment forced me to use lock cookie as an authentication key for the lock. This means that a client trying to update or delete a record need lock this first then update or delete. So my GUI for client work as follow :
1. A client tries to book a room. Click on "Book" button -> check if record is locked, if not -> lock record -> GUI gives popup window to fill in consumerID
2. The client fill in the customerID and press enter. Check if input valid, if yes -> send customerID and update record -> unlock record

So the scenario I imagine is that the client will always lock at start before starting to edit or delete. The editing and deleting will take a few seconds or minutes before it is committed. If this happens, and I let other clients, who want to access the same record, wait until the first client finished. It will take a long time for the other clients to access the same record. This is actually the main reason why I feel strongly that waiting is not an option.

I'm not being stubborn here, but I just want to make clear of my situation and I would like to know whether the "must" requirements cannot be avoided with explanation on decision.txt.



PS: Example of escaping "must" requirement I found in the forum is that many people implement 3-tier architecture instead of 2-tier
Hi ranchers,

I've been busy with my SCJD assignment for a few months now. I'm almost finished and just need to document everything but while documenting, I wonder if my locking mechanism will be acceptable or not.

I understand that the assignment stated that a thread must wait when a record is locked until the locked is released. I wanted to implement this at the beginning, but it just doesn't make sense for me. This is why I think the waiting doesnt make sense:

Imagine that 2 users want to access the same record and user 1 has the lock first. So the user 2 has to wait. Now user 1 has updated the size of the room, or/and the smoking possibility for the room for example. Then user 1 is done with his action, he releases the lock on the record. Then come user 2. He gets the key and he wants to book the record. He was looking for a room with size 2 with no smoking possibility. But this was changed by user 1. So why would he now book this room? Same thing as user 1 delete record and user 2 waits for it, user 2 will only get RecordNotFoundException. So why bother waiting?

Next to that how will you show the GUI that someone else is busy with the record, and how long he must wait for the locked record?

I've been looking in the forum, and it seems everyone thinks that lock mechanism has to wait, but I just cant agree about it. Please give me some input for this problem.

Thank you.


Wow Roel, you made me change my perspective. Of course... it should be possible to remove the RNFE and not using it instead of forcing the method to throw it. Thanks for the idea.
Hi guys,

I have also faced this problem and thought about it. The delete process will have to be lock() -> delete() -> unlock() , so which means that throwing RNFException on unlocking will always happen if the condition to throw RNFException is record not existing or deleted. This does not make sense.

Post 04 April 2009 16:27:58 Subject: unlock method question

It could be when you try to unlock a record that doesn't exist... obviously, this is not likely to happen in your application, but we have to think that we are creating these APIs for other people to use, you know... so if someone uses it wrongly, then we're prepared.

Even if someone else is trying to use this API, why would he/she unlock something that is not locked.

My solution to locking records in the database is using Map<Integer,Long> so every record that is locked is registered.

So the only condition I can consider of throwing RNFException is when the record number entered is not registered in the Map.

PS : the specification on the assignment about throwing RNFException is
Any methods that throw RecordNotFoundException should do so if a specified record does not exist or is marked as deleted in the database file.
It's not a must statement, so it should be safe if you dont fully follow it.