#139 @Tab doesn't work with @AttributeOverride

v4.2.1
closed
nobody
None
5
2011-07-07
2010-08-30
Roy Hellinga
No

In OpenXava 3.1.4, SQL queries generated by JDBCTabProvider do not have the correct column name when @AttributeOverride is used. I have done a little debugging, and the 'fields' String[] in JDBCTabProvider has the incorrect values.

In my scenario, I need to use @AttributeOverride because I am using @Embedded for my Address implementation and I have some entities with multiple addresses (e.g. billing address and shipping address). In that case, Hibernate requires that at least one set of columns needs to use @AttributeOverride to prevent duplicate column names in the generated table DDL.

Javier suggested "There is no test using @AttributeOverride in OpenXavaTest so surely it's a bug."

Discussion

  • Hi Roy,

    Can you put here a simple test case for this behaviour?

    Federico

     
  • Roy Hellinga
    Roy Hellinga
    2010-10-06

    I think this is the test case for this bug (although I'm not certain of it -- it has been a while and my original code is changed). My real application's Address class is more complicated than this (with associations to Province and Country entities), this test application is simpler:

    First, an @Embeddable class:

    @Embeddable
    public class Address {
    private String addrStreetAddress;
    private String addrCity;
    private String addrState;
    private String addrPostCode;
    ...

    Second, an entity that calls embeds that class at least twice:

    @Entity
    @Tab(properties="custName,custShipToAddr.addrStreetAddress,custBillToAddr.addrStreetAddress")
    public class Customer {
    @Id
    @Hidden
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(length = 8)
    private int custId;
    @Column
    private String custName;
    @Embedded
    private Address custShipToAddr;
    @Embedded
    @AttributeOverrides({
    @AttributeOverride(name="addrStreetAddress",column=@Column(name="shipStreetAddress")),
    @AttributeOverride(name="addrCity",column=@Column(name="shipCity")),
    @AttributeOverride(name="addrState",column=@Column(name="shipState")),
    @AttributeOverride(name="addrPostCode",column=@Column(name="shipPostCode"))
    })
    private Address custBillToAddr;
    ...

    For me this generates the following error in the log:
    "Mapping not found for custBillToAddr_addrStreetAddress in Customer". I'm not certain this is the original error, since my bug report speaks of invalid SQL being generated, and this isn't getting that far. In any case, this example provides the structure of what OX needs to support.

     
  • Javier Paniza
    Javier Paniza
    2011-07-07

    • milestone: --> v4.2.1
    • status: open --> closed-fixed