You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomee.apache.org by Manu George <ma...@gmail.com> on 2007/02/17 18:12:57 UTC

Automatic mapping of CMP fields

Hi,
     As per my knowledge, currently in openejb for mapping of the ejb
fields to the database columns we use the jpa.mapping.xml file. Do we
still need the cmp.mapping.xml?

Secondly does oejb have the ability to automatically do the mapping
during deployment. eg If the user puts the <automap> tag in the dd
then openejb should try to auto map during deployment. Probably the
table names need to be mapped by to the EJB by the user if they are
different from the ejb names. We can also specify whether the mapping
should be by name (ejb fields and table fields)or by type.
This should enable openejb to generate the mapping automatically
instead of the user specifying them.

Some app servers provide this functionality. Is a similar feature there in OEJB?

Regards
Manu

Re: Automatic mapping of CMP fields

Posted by Dain Sundstrom <da...@iq80.com>.
Our CMP implementation is simply a thin layer over JPA.  For each CMP  
entity, we create a JPA entity, and for each CMP or CMR field, we  
create a field in the JPA entity.  The name of the entity is either  
the abstract schema name of the CMP entity as declared in the ejb- 
jar.xml file, or if the abstract schema name is not declared, it is  
the ejb name processed with the following code:

     ejbName.trim().replaceAll("[ \\t\\n\\r-]+", "_");

Basically, that is all sequences of white space and '-' replaced with  
a single underscore.

Now that you know how we map a CMP entity to a JPA entity, following  
the default mapping rules in the JPA specification, you can determine  
the mapping for your CMP beans... but that would be work, so I'll  
just repeat the rules here :)   Each JPA entity is mapped to a table  
with the same name as the entity, and each field (id, basic,  
association) is mapped to a column of the same name.  Pretty simple.

-dain

On Feb 17, 2007, at 9:12 AM, Manu George wrote:

> Hi,
>     As per my knowledge, currently in openejb for mapping of the ejb
> fields to the database columns we use the jpa.mapping.xml file. Do we
> still need the cmp.mapping.xml?
>
> Secondly does oejb have the ability to automatically do the mapping
> during deployment. eg If the user puts the <automap> tag in the dd
> then openejb should try to auto map during deployment. Probably the
> table names need to be mapped by to the EJB by the user if they are
> different from the ejb names. We can also specify whether the mapping
> should be by name (ejb fields and table fields)or by type.
> This should enable openejb to generate the mapping automatically
> instead of the user specifying them.
>
> Some app servers provide this functionality. Is a similar feature  
> there in OEJB?
>
> Regards
> Manu


Re: Automatic mapping of CMP fields

Posted by Mohammad Nour El-Din <no...@gmail.com>.
Hi Manu...

Sure I will, and I am very happy to argue your brilliant ideas with you :D



On 2/18/07, Manu George <ma...@gmail.com> wrote:

> Hi Mohammad,
>
>         Thanks for the answers.  What I proposed was that these be
> optional. Only if the developer knows that the names are the same/ or
> the type convention is followed he will specify the automapping.
> Otherwise he needs to do the mapping himself.
>
> I totally agree with you that it should be in the tools project, and
> you are right I saw it in IBM Websphere RAD :).
>
> I just wanted to get that feature in there somewhere as it is very
> convenient during development. Please note it as a feature to be added
> in the tools sub-project :).
>
> Thanks
> Manu
>
> On 2/18/07, Mohammad Nour El-Din <no...@gmail.com> wrote:
> > Hi Manu...
> >
> > If you please, as per my knowledge I want to argue your ideas with you.
> Your
> > ideas sounds great, but IMHO I can tell that it will face some technical
> > difficulties, please see my comments on each idea below
> >
> >
> >
> > On 2/17/07, Manu George <ma...@gmail.com> wrote:
> >
> > > Hi,
> > >     As per my knowledge, currently in openejb for mapping of the ejb
> > > fields to the database columns we use the jpa.mapping.xml file. Do we
> > > still need the cmp.mapping.xml?
> >
> >
> > I think Dain is the one who can answer this
> >
> > Secondly does oejb have the ability to automatically do the mapping
> > > during deployment. eg If the user puts the <automap> tag in the dd
> > > then openejb should try to auto map during deployment. Probably the
> > > table names need to be mapped by to the EJB by the user if they are
> > > different from the ejb names. We can also specify whether the mapping
> > > should be by name (ejb fields and table fields)or by type.
> > > This should enable openejb to generate the mapping automatically
> > > instead of the user specifying them.
> >
> >
> > First regarding mapping EJB Entity bean(s) and their fields using names,
> you
> > have to make sure that the Database designer is following some naming
> scheme
> > so OpenEJB can map EJB(s) to table(s) and member field(s) to field(s),
> which
> > is not the case most of the time, as the Database design is done
> parallel to
> > the Application design and it has to has no effect on  the Application
> > design at all.
> >
> > Second, if we will use types instead of names or with names, we can not
> > guarantee that the Database designer or the Application designer are
> > following the Java types to Database types *convention* -  and take care
> > that it is a convention not a standard -, and even, this convention is
> not
> > valid for all RDBMS, we faced this situation before here at IBM as we
> were
> > supporting more than one RDMBS, and we found that it is not always the
> same
> > for all situations.
> >
> > Some app servers provide this functionality. Is a similar feature there
> in
> > > OEJB?
> >
> >
> > You are right, and sorry if my opinions above can make you disappointed,
> but
> > your ideas can be accomplished, but we have to ask our selves, what is
> the
> > main target of doing this, IMHO it is to make the development task
> easier
> > for developers, but not so hard for Container developers too :), so we
> can
> > do the flexibility in another place, which is using Tools - as we
> started to
> > have our own Tools project .
> >
> > The current way is called - in terms of IBM WebSphere - *Meet In The
> > Middle*, that is you have Database and EJB(s) and you want to map
> between
> > them, at this situation you have to have a mapping given to the
> container.
> > Another situation, that is you have a Database and want to create EJB(s)
> > based on this Database. Another one when you have EJB(s) and want to
> create
> > Database based on them. All of these situation, which I think are the
> most
> > common situations one can have, are supported in a flexible way using
> IBM
> > tools - whether WAST, RAD, RSA.
> >
> > To summarize, we have to invest these ideas in the Tools project not in
> the
> > container it self because the role of the container is to find a mapping
> to
> > make its job easier and more focused.
> >
> >
> > Regards
> > > Manu
> > >
> >
> >
> >
> > --
> > Thanks
> > - Mohammad Nour
> >
>



-- 
Thanks
- Mohammad Nour

Re: Automatic mapping of CMP fields

Posted by Manu George <ma...@gmail.com>.
Hi Mohammad,

         Thanks for the answers.  What I proposed was that these be
optional. Only if the developer knows that the names are the same/ or
the type convention is followed he will specify the automapping.
Otherwise he needs to do the mapping himself.

 I totally agree with you that it should be in the tools project, and
you are right I saw it in IBM Websphere RAD :).

I just wanted to get that feature in there somewhere as it is very
convenient during development. Please note it as a feature to be added
in the tools sub-project :).

Thanks
Manu

On 2/18/07, Mohammad Nour El-Din <no...@gmail.com> wrote:
> Hi Manu...
>
> If you please, as per my knowledge I want to argue your ideas with you. Your
> ideas sounds great, but IMHO I can tell that it will face some technical
> difficulties, please see my comments on each idea below
>
>
>
> On 2/17/07, Manu George <ma...@gmail.com> wrote:
>
> > Hi,
> >     As per my knowledge, currently in openejb for mapping of the ejb
> > fields to the database columns we use the jpa.mapping.xml file. Do we
> > still need the cmp.mapping.xml?
>
>
> I think Dain is the one who can answer this
>
> Secondly does oejb have the ability to automatically do the mapping
> > during deployment. eg If the user puts the <automap> tag in the dd
> > then openejb should try to auto map during deployment. Probably the
> > table names need to be mapped by to the EJB by the user if they are
> > different from the ejb names. We can also specify whether the mapping
> > should be by name (ejb fields and table fields)or by type.
> > This should enable openejb to generate the mapping automatically
> > instead of the user specifying them.
>
>
> First regarding mapping EJB Entity bean(s) and their fields using names, you
> have to make sure that the Database designer is following some naming scheme
> so OpenEJB can map EJB(s) to table(s) and member field(s) to field(s), which
> is not the case most of the time, as the Database design is done parallel to
> the Application design and it has to has no effect on  the Application
> design at all.
>
> Second, if we will use types instead of names or with names, we can not
> guarantee that the Database designer or the Application designer are
> following the Java types to Database types *convention* -  and take care
> that it is a convention not a standard -, and even, this convention is not
> valid for all RDBMS, we faced this situation before here at IBM as we were
> supporting more than one RDMBS, and we found that it is not always the same
> for all situations.
>
> Some app servers provide this functionality. Is a similar feature there in
> > OEJB?
>
>
> You are right, and sorry if my opinions above can make you disappointed, but
> your ideas can be accomplished, but we have to ask our selves, what is the
> main target of doing this, IMHO it is to make the development task easier
> for developers, but not so hard for Container developers too :), so we can
> do the flexibility in another place, which is using Tools - as we started to
> have our own Tools project .
>
> The current way is called - in terms of IBM WebSphere - *Meet In The
> Middle*, that is you have Database and EJB(s) and you want to map between
> them, at this situation you have to have a mapping given to the container.
> Another situation, that is you have a Database and want to create EJB(s)
> based on this Database. Another one when you have EJB(s) and want to create
> Database based on them. All of these situation, which I think are the most
> common situations one can have, are supported in a flexible way using IBM
> tools - whether WAST, RAD, RSA.
>
> To summarize, we have to invest these ideas in the Tools project not in the
> container it self because the role of the container is to find a mapping to
> make its job easier and more focused.
>
>
> Regards
> > Manu
> >
>
>
>
> --
> Thanks
> - Mohammad Nour
>

Re: Automatic mapping of CMP fields

Posted by Mohammad Nour El-Din <no...@gmail.com>.
Hi Manu...

If you please, as per my knowledge I want to argue your ideas with you. Your
ideas sounds great, but IMHO I can tell that it will face some technical
difficulties, please see my comments on each idea below



On 2/17/07, Manu George <ma...@gmail.com> wrote:

> Hi,
>     As per my knowledge, currently in openejb for mapping of the ejb
> fields to the database columns we use the jpa.mapping.xml file. Do we
> still need the cmp.mapping.xml?


I think Dain is the one who can answer this

Secondly does oejb have the ability to automatically do the mapping
> during deployment. eg If the user puts the <automap> tag in the dd
> then openejb should try to auto map during deployment. Probably the
> table names need to be mapped by to the EJB by the user if they are
> different from the ejb names. We can also specify whether the mapping
> should be by name (ejb fields and table fields)or by type.
> This should enable openejb to generate the mapping automatically
> instead of the user specifying them.


First regarding mapping EJB Entity bean(s) and their fields using names, you
have to make sure that the Database designer is following some naming scheme
so OpenEJB can map EJB(s) to table(s) and member field(s) to field(s), which
is not the case most of the time, as the Database design is done parallel to
the Application design and it has to has no effect on  the Application
design at all.

Second, if we will use types instead of names or with names, we can not
guarantee that the Database designer or the Application designer are
following the Java types to Database types *convention* -  and take care
that it is a convention not a standard -, and even, this convention is not
valid for all RDBMS, we faced this situation before here at IBM as we were
supporting more than one RDMBS, and we found that it is not always the same
for all situations.

Some app servers provide this functionality. Is a similar feature there in
> OEJB?


You are right, and sorry if my opinions above can make you disappointed, but
your ideas can be accomplished, but we have to ask our selves, what is the
main target of doing this, IMHO it is to make the development task easier
for developers, but not so hard for Container developers too :), so we can
do the flexibility in another place, which is using Tools - as we started to
have our own Tools project .

The current way is called - in terms of IBM WebSphere - *Meet In The
Middle*, that is you have Database and EJB(s) and you want to map between
them, at this situation you have to have a mapping given to the container.
Another situation, that is you have a Database and want to create EJB(s)
based on this Database. Another one when you have EJB(s) and want to create
Database based on them. All of these situation, which I think are the most
common situations one can have, are supported in a flexible way using IBM
tools - whether WAST, RAD, RSA.

To summarize, we have to invest these ideas in the Tools project not in the
container it self because the role of the container is to find a mapping to
make its job easier and more focused.


Regards
> Manu
>



-- 
Thanks
- Mohammad Nour