Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multi-table-entity insert before test #39

Open
xxlabaza opened this issue Nov 1, 2014 · 0 comments
Open

Multi-table-entity insert before test #39

xxlabaza opened this issue Nov 1, 2014 · 0 comments

Comments

@xxlabaza
Copy link

xxlabaza commented Nov 1, 2014

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant