1 Reply Latest reply on Sep 11, 2002 3:58 PM by marc fleury

    Validation and ejbStore

    Kelly MacInnis Newbie

      Here is the problem,

      I have a complicated database with 25 tables, many to many relationships, beans that use other beans as children, instances where a bean needs to call a stored procedure in the database to handle stuff, and lots of business logic. When a client wants to change something there is a lot of validation. Since you can’t tell when the container is going to store the changes, doing the validation in ejbStore is not an option. The exceptions that come back are buried three or four levels deep and the client may be long gone from where they set the data in the bean. The validation needs to happen when they set the data. The problem is there is time between setData and the store where some other user or another process can change something in the database that could make what was valid become invalid.

      Is there a way to start some transaction and lock records before the store? Or a way to force the container to store while the client is still around to find out what happened?

      Any ideas?

        • 1. Re: Validation and ejbStore
          marc fleury Master

          It's a bad one.

          One way is to use "select for update" or similar to make sure that when the data is loaded you lock the rows. This is however VERY BAD as it will lead ALMOST CERTAINLY to poor throughput and even deadlock.

          There are several ways. If you are using 3.0 then you can use client side interceptors to do validation on the client. If the data depends on server side stuff then you want to reach it and then do validation as they set (or are done setting if it is a complex validation) and then recheck as you write.