|
Replies:
2
-
Last Post:
May 3, 2007 12:12 AM
by: Shevland, Joe
|
|
|
|
|
|
|
RE: EJBQL Exception
Posted:
Apr 30, 2007 9:47 PM
|
|
|
> While @ManyToOne (or any other relationship annotation) is > required, the @Column or @JoinColumn are optional - if your > mapping is the same as the defaults defined in the spec, you > don't need them.
Makes sense; I'd say though the cases where you don't need to define a property->column mapping are pretty rare (almost restricted to tutorials and shallow examples I'd say) - all projects I've worked on to date have either had a legacy database, or a schema that's being dictated by DBA's/database standards for column names etc. A JPA-generated database schema is probably not going to be very good if you don't use the Column mapping for things like length, nullability etc. Or on the other hand, you'd have getters/setters like getPrs_Fst_Nm() which I personally wouldn't allow in a codebase.
Cheers Joe
This message contains information that may be privileged or confidential and is the property of the Capgemini Group. It is intended only for the person to whom it is addressed. If you are not the intended recipient, you are not authorized to read, print, retain, copy, disseminate, distribute, or use this message or any part thereof. If you receive this message in error, please notify the sender immediately and delete all copies of this message.
--------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscribe@glassfish.dev.java.net For additional commands, e-mail: users-help@glassfish.dev.java.net
|
|
|
|
|
|
|
Re: EJBQL Exception
Posted:
Apr 30, 2007 9:56 PM
in response to: Shevland, Joe
|
|
|
Shevland, Joe wrote: >>While @ManyToOne (or any other relationship annotation) is >>required, the @Column or @JoinColumn are optional - if your >>mapping is the same as the defaults defined in the spec, you >>don't need them. > > > Makes sense; I'd say though the cases where you don't need to define a > property->column mapping are pretty rare (almost restricted to tutorials > and shallow examples I'd say) - all projects I've worked on to date have > either had a legacy database, or a schema that's being dictated by > DBA's/database standards for column names etc. A JPA-generated database > schema is probably not going to be very good if you don't use the Column > mapping for things like length, nullability etc. Or on the other hand, > you'd have getters/setters like getPrs_Fst_Nm() which I personally > wouldn't allow in a codebase.
Agree 
-marina
> > Cheers > Joe > > This message contains information that may be privileged or confidential and is the property of the Capgemini Group. It is intended only for the person to whom it is addressed. If you are not the intended recipient, you are not authorized to read, print, retain, copy, disseminate, distribute, or use this message or any part thereof. If you receive this message in error, please notify the sender immediately and delete all copies of this message. > > --------------------------------------------------------------------- > To unsubscribe, e-mail: users-unsubscribe@glassfish.dev.java.net > For additional commands, e-mail: users-help@glassfish.dev.java.net >
--------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscribe@glassfish.dev.java.net For additional commands, e-mail: users-help@glassfish.dev.java.net
|
|
|
|
|
|
|
|
RE: RE: EJBQL Exception
Posted:
May 3, 2007 12:12 AM
in response to: Shevland, Joe
|
|
|
> Thanks much for your suggestions. It took me a while to > implement the attributions as initially addition of the > ManyToOne attribute caused the app server to hang. I > eventually realized this was because the SelCat entity was > referenced to the Seller entity only by its ID attribute (a > String). I replaced this with an object reference, which > resolved that problem.
Not sure whether the app server should hang with a dodgy entity definiton; might be worth filing a bug.
> If I may ask one follow up question, with regard to the Query > (using your simplified suggestion) in the Java method, to > reference the attribute in the joined table do I use dot > notation (i.e. select s from Sellers where s.Selcat.selcatid > = :selcatID)? I've been hunting for an answer in > documentation and the web and can't seem to find one.
In the query you reference the Java property names (irrespective of whether the annotation is on the property or getter method); so if in Seller you have the SellerCategory object defined as, say,
@... private SellerCategory sellerCategory;
Then in the query it'll be:
from Seller seller where seller.sellerCategory.id = :id
Cheers Joe
This message contains information that may be privileged or confidential and is the property of the Capgemini Group. It is intended only for the person to whom it is addressed. If you are not the intended recipient, you are not authorized to read, print, retain, copy, disseminate, distribute, or use this message or any part thereof. If you receive this message in error, please notify the sender immediately and delete all copies of this message.
--------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscribe@glassfish.dev.java.net For additional commands, e-mail: users-help@glassfish.dev.java.net
|
|
|
|
|