Menu

#362 Multi-table-entity insert before test

v2.5.*
closed-invalid
nobody
(not fixed)
7
2015-01-26
2014-11-01
No

Hi!

I have an Entity from two tables, like this one:

@Entity
@Table(name = "admin_goods_cat_soft")
@SecondaryTable(name = "c_categories",
                pkJoinColumns = @PrimaryKeyJoinColumn(name = "id",
                                                      referencedColumnName = "a_id"))
public class ProductSoftCategory implements Serializable {

    private static final long serialVersionUID = -1186100819002788670L;

    @Id
    @GeneratedValue
    @Column(name = "a_id")
    private Integer id;

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "parent_id", table = "c_categories", referencedColumnName = "a_id")
    private ProductSoftCategory parent;

    @Column(name = "name", table = "c_categories")
    private String name;

    @Column(name = "a_alias")
    private String alias;

    // other fields from `admin_goods_cat_soft ` and `c_categories ` tables

The entity contains some columns from two tables, but not all of them.

DbUnit schema has description of these tables:

<!ELEMENT c_categories EMPTY>
<!ATTLIST c_categories
    id CDATA #REQUIRED
    parent_id CDATA #IMPLIED
    template_id CDATA #IMPLIED
    key_id CDATA #IMPLIED
    enum_value_id CDATA #IMPLIED
    name CDATA #REQUIRED
    alias CDATA #IMPLIED
    image_url CDATA #IMPLIED
    level CDATA #REQUIRED
    sort CDATA #IMPLIED
    discount_category_id CDATA #IMPLIED
    dont_use_in_search CDATA #IMPLIED
    is_hidden CDATA #IMPLIED
>
<!ELEMENT admin_goods_cat_soft EMPTY>
<!ATTLIST admin_goods_cat_soft
    a_id CDATA #REQUIRED
    a_alias CDATA #REQUIRED
    title CDATA #IMPLIED
    description CDATA #IMPLIED
    image_url CDATA #IMPLIED
    dont_show_children CDATA #IMPLIED
    model_grouping_keys CDATA #IMPLIED
    external_link CDATA #IMPLIED
    show_in_tree CDATA #IMPLIED
    cat_model_grouping_keys CDATA #IMPLIED
    mxp_description CDATA #IMPLIED
    is_new CDATA #IMPLIED
>

Before some test class I try to write the values in database by DbUnit:

<c_categories id="1"
              name="Root"/>

<admin_goods_cat_soft a_id="1"
                      a_alias="root"
                      title="Root category"/>

... but test fails down at this step with the following exception:

org.dbunit.dataset.NoSuchColumnException: c_categories.TEMPLATE_ID -  (Non-uppercase input column: template_id) in ColumnNameToIndexes cache map. Note that the map's column names are NOT case sensitive.

It's strange, because I don't event use a c_categories.TEMPLATE_ID column in my Entity. Please, help me to solve this bug, because it stops my work for two days...

P.S. sorry for my English, it's not my native language

Discussion

  • Jeff Jensen

    Jeff Jensen - 2014-11-29
    • status: open --> closed-invalid
     
  • Jeff Jensen

    Jeff Jensen - 2014-11-29

    dbUnit fields match the database, not entities.
    Your schema has a field named template_id. If the database does not have it, that's probably an issue.

    Until you have found a defect, please use the user list for further help, as you are reporting your probable configuration problem as a defect.

     

Log in to post a comment.