just kidding with cmp...

Discussion in 'Java' started by Andrea Sansottera, Jul 16, 2004.

  1. Hi all guys,
    I'm looking for a few suggestions on ejb cmp. I'm using j2ee sdk 1.4,
    pointbase database server.
    1) I have too check for the values of a few properties of an entity bean
    before they are stored on the database. For example, I have in my bean
    class:

    public abstract void setAcidity(double acidity);

    but I want, for instance, acidity to be greater than -4... how can I do
    this? Should I use bean managed persistance and write jdbc code for *all*
    the properties of my entity bean class?

    2) Again... I want to allow some method calls only to the users which have
    the "employer" role, but they should also have a certain value on certain
    field of a column (editable=true), otherwise the operation should not be
    done... shall I do this only with bean managed persistance?

    Thanks a lot, any suggestion is appreciated.

    Andrea
     
    Andrea Sansottera, Jul 16, 2004
    #1
    1. Advertising

  2. In article <>,
    Andrea Sansottera <> wrote:

    > but I want, for instance, acidity to be greater than -4... how can I do
    > this?


    What you are describing are business rules. Normally, those would be
    implemented in a layer above the persistence level.

    For example, some session bean might have an addItem() or updateItem()
    method that took a number of parameters and validated them before
    setting entity bean properties.

    The same design can be applied to your second example, possibly combined
    with a finder method that checks the appropriate column using EJB QL.

    --
    Phillip Mills
    Multi-platform software development
    (416) 224-0714
     
    Phillip Mills, Jul 16, 2004
    #2
    1. Advertising

  3. Thanks for the good advice... so I'm going to create a new tier:

    web tier (user interface)
    session beans (business rules)
    entity beans
    database tables (automatically generated)

    Is it right?

    Another question: why should I not create a cmp ejb with no persistance
    fields? It has to have only two foreign keys (that is, relationship fields)...

    On Fri, 16 Jul 2004 08:16:11 -0400, Phillip Mills wrote:

    > In article <>,
    > Andrea Sansottera <> wrote:
    >
    >> but I want, for instance, acidity to be greater than -4... how can I do
    >> this?

    >
    > What you are describing are business rules. Normally, those would be
    > implemented in a layer above the persistence level.
    >
    > For example, some session bean might have an addItem() or updateItem()
    > method that took a number of parameters and validated them before
    > setting entity bean properties.
    >
    > The same design can be applied to your second example, possibly combined
    > with a finder method that checks the appropriate column using EJB QL.
     
    Andrea Sansottera, Jul 16, 2004
    #3
  4. Andrea Sansottera

    Sudsy Guest

    Andrea Sansottera wrote:
    > Thanks for the good advice... so I'm going to create a new tier:
    >
    > web tier (user interface)
    > session beans (business rules)
    > entity beans
    > database tables (automatically generated)
    >
    > Is it right?


    Congrats! You have arrived at the architecture most commonly used and
    recommended. Mr. Mills offered sagacious advice.
    I like this approach as it removes dependency on the underlying data
    store. Things like stored procedures and triggers are non-portable.
    Ever try to port Progress triggers to Oracle PL/SQL? :-(
     
    Sudsy, Jul 16, 2004
    #4
  5. On Fri, 16 Jul 2004 09:23:02 -0400, Sudsy wrote:


    > Congrats! You have arrived at the architecture most commonly used and
    > recommended. Mr. Mills offered sagacious advice.
    > I like this approach as it removes dependency on the underlying data
    > store. Things like stored procedures and triggers are non-portable.


    I'm happy what I'm learning is right :)

    > Ever try to port Progress triggers to Oracle PL/SQL? :-(


    I'm not very found on SQL's advanced features and I've never used Oracle
    (too expansive)...
     
    Andrea Sansottera, Jul 16, 2004
    #5
  6. In article <>,
    Andrea Sansottera <> wrote:

    > Another question: why should I not create a cmp ejb with no persistance
    > fields? It has to have only two foreign keys (that is, relationship
    > fields)...


    If you mean for many-to-many relationships, usually you can let CMR take
    care of that for you.

    For example:
    A BooksEB can return a Collection from a getReaders() method and a
    ReadersEB can have getBooks() and the right CMR descriptors will just
    make it work. However, I'm always a bit nervous when I do this because
    some day I may want to know the date that Reader X first borrowed Book
    Y. That information would belong in the connecting table, which --
    unless someone knows some interesting tricks -- would mean replacing the
    CMR with an explicit table/entity.

    --
    Phillip Mills
    Multi-platform software development
    (416) 224-0714
     
    Phillip Mills, Jul 16, 2004
    #6
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Andrea Sansottera

    no cmp field defined in cmp ejb

    Andrea Sansottera, Jul 16, 2004, in forum: Java
    Replies:
    0
    Views:
    410
    Andrea Sansottera
    Jul 16, 2004
  2. walterbyrd
    Replies:
    1
    Views:
    381
    Damjan
    Apr 10, 2006
  3. Ark Khasin

    Is it just me or just Microsoft?

    Ark Khasin, Jul 15, 2007, in forum: C++
    Replies:
    24
    Views:
    773
    Lionel B
    Jul 16, 2007
  4. Ark Khasin

    Is it just me or just Microsoft?

    Ark Khasin, Jul 15, 2007, in forum: C Programming
    Replies:
    42
    Views:
    1,149
    user923005
    Jul 17, 2007
  5. Victor Bazarov
    Replies:
    9
    Views:
    752
    MikeWhy
    Feb 13, 2012
Loading...

Share This Page