Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
RE: [eclipselink-dev] what do you think of the following @Embedded extension

Thanks for your reply James!

I was just wondering if there is any other major improvement in the @Embedded handling in JPA-2.0 other than nested embeddings. According to the JSR-317 overview page, making @Embedded more usable is one of the primary goals. 

I already started implementing the @Embedded extension, and if I really get it done, I'll post my patch. I move the functionality to a separate Annotation if it's finished.

txs and LieGrue,
strub

PS: I've also 'mavenized' the core parts of eclipselink and will provide a git archive later this week if there is any interest.



--- James Sutherland <JAMES.SUTHERLAND@xxxxxxxxxx> schrieb am Mo, 10.11.2008:

> Von: James Sutherland <JAMES.SUTHERLAND@xxxxxxxxxx>
> Betreff: RE: [eclipselink-dev] what do you think of the following @Embedded extension
> An: "Dev mailing list for Eclipse Persistence Services" <eclipselink-dev@xxxxxxxxxxx>
> Datum: Montag, 10. November 2008, 15:06
> The solution for this in JPA is to use the
> @AttributeOverrides.
> 
> The prefix sounds like it could be a useful feature;
> perhaps log an enhancement request for it.  It is not part
> of JPA, so would need to be its own extension annotation,
> i.e. @EmbeddedPrefix("N_").
> 
> 
> -----Original Message-----
> From: Mark Struberg [mailto:struberg@xxxxxxxx]
> Sent: Sunday, November 09, 2008 5:37 PM
> To: eclipselink-dev@xxxxxxxxxxx
> Subject: [eclipselink-dev] what do you think of the
> following @Embedded extension
> 
> Hi!
> 
> I hope my post isn't getting too confusing, so I'd
> like to start with a question:
> 
> I came across a problem while embedding the same
> @Embeddable class 2 times in an @Entity:
> 
> Let's assume I have a Price which always looks the
> same:
>    @Embeddable
>    public class Price {
>         public BigDecimal amount;
>         public String currency;
>    }
>   
> and I'd like to use this Price for storing the net
> price and the price including all the taxes:
>    @Entity
>    public class Purchase {
>         @Embedded
>         private Price netPrice;
>   
>         @Embedded
>         private Price grossPrice;
>    }
> 
> You know, we are used to fumble around with
> @AttributeOverrides, but to be honest, this is not
> satisfyingly (this did e.g. work really well in JDO), since
> it lacks a proper handling for nested embeddings, etc.
> 
> So, maybe there is already a solution for this problem, and
> I simply didn't find it. I know there has been some
> discussions about nested embedded fields, but I didn't
> find my problem covered in the JPA-2.0 spec.
> If it's not fixed already, I would be glad if JPA 2.0
> would introduce a way to manually set a prefix for all
> fields of the embedded class, which would look something
> like the following example:
> 
>    @Entity
>    public class Purchase {
>         @Embedded(prefix="N_")
>         private Price netPrice;
>   
>         @Embedded(prefix="G_")
>         private Price grossPrice;
>    }
> 
> Which would generate the database columns
> N_AMOUNT
> N_CURRENCY
> G_AMOUNT
> G_CURRENCY
> 
> For nested embeddings, the prefixes would simply stack.
> 
> What do you think about this?
> Or is there a better solution, and I was only too blind to
> see it?
> 
> txs in advance and LieGrue,
> strub
> 
> 
> 
> _______________________________________________
> eclipselink-dev mailing list
> eclipselink-dev@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/eclipselink-dev
> _______________________________________________
> eclipselink-dev mailing list
> eclipselink-dev@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/eclipselink-dev





Back to the top