Justforfly @JoinColumn Doubt

Source: Internet
Author: User

http://www.oschina.net/question/54953_45536


@JoinColumn Question Justforfly on 3-23 15:48 2 months ago, 1 back/281 read, finally replied: 2 months ago (0 people to collect this topic, I want to collect | report) Discussion Area» Technical FAQ Top 0 Tread two sheet structure as follows Table_a:id, COLA1, COLA2
Table_b:id, a_id, COLB1, COLB2
A and B are a one-to-many relationship. I set up the following relationship through Anotation on the B bean. @ManyToOne (cascade = Cascadetype.refresh, targetentity = table_a.class) @JoinColumn (name = "A_ID", referencedcolumnname = "ID", nullable = True, Insertable = false, updatable = False)
Now the problem comes, is in table_b.a_id = table_a.id at the same time, also request Table_b.colb1= "ABC".
I would like to ask you how this situation is handled. How to use @joincolumn. Tags: Hibernate I want to ask the same question a total of 0 people want to ask the same question to
add a topic Note» A total of 1 additional instructions justforfly: In Hibernate this aspect, who is more experienced, hope to guide twos. can only use SQL to solve this problem. 2 months ago by rating | Show the latest answer | Back to the top of the page there are 1 answers I want to answer» justforfly answer in 2012-03-31 11:12 (2 months ago) report

I finally solve the problem, share the code, hope can also help others.

1 @ManyToOne (cascade = Cascadetype.refresh, targetentity = table_a.class)
2 @JoinColumnsOrFormulas (value={@JoinColumnOrFormula (column= @JoinC Olumn (name = "A_ID", referencedcolumnname = "ID", nullable = True, Insertable = false, updatable = False))
3        &nbs P;        &NBSP, @JoinColumnOrFormula (formula= @JoinFormula (value= "") ABC ' ", referencedcolumnname =" COLB1 "))
4                         &NBSP})

The emphasis is on @joinformula use (similar to @joincolumn):

Value indicates the value of the corresponding column (the SQL expression can also be written here), and the

Referencedcolumnname indicates the name of the column

because there are more than one association relationship, you need to include multiple criteria by using labels such as @joincolumnsorformulas, @JoinColumns, @JoinrFormulas. Helpful (0) | No Help (0) | Comments (0) | Reference to this answer


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.