Appian Community
Site
Search
Sign In/Register
Site
Search
User
DISCUSS
LEARN
SUCCESS
SUPPORT
Documentation
AppMarket
More
Cancel
I'm looking for ...
State
Not Answered
Replies
3 replies
Subscribers
9 subscribers
Views
1975 views
Users
0 members are here
Share
More
Cancel
Related Discussions
Home
»
Discussions
»
General
I am trying to configure a CDT to use the JPA ManyToMany Annotation. I have two
bend
over 12 years ago
I am trying to configure a CDT to use the JPA ManyToMany Annotation. I have two objects A & B. Many A's can have many B's and many B's can have many A's. A has a primary key of id which is AutoGenerated, and a name field. B is setup the same way as A. In A I add the following element:
<xsd:element name="bid" type="B" nillable="true" minOccurs="0" maxOccurs="unbounded">
<xsd:annotation> <xsd:appinfo source="appian.jpa">
@ManyToMany
@JoinTable(name="a_b",
joinColumns=@JoinColumn(name="aid", referencedColumnName="id"),
inverseJoinColumns=@JoinColumn(name="bid",referencedColumnName="id")
)
</xsd:appinfo></xsd:annotation> </xsd:element>
I import the CDT and the tables for A & B generate correctly. My problem is that when I create a new A and select B from a dropdown list to store in the a_b JoinTable my B name field is updated to null. What do I need to do to only have the JoinTable records updated and not the actual reco...
OriginalPostID-59912
OriginalPostID-59912
Discussion posts and replies are publicly visible
0
bend
over 12 years ago
...rds? I have read about using 2 OneToMany's with a JoinTable but I don't think this is supported by Appian JPA at this time. Any examples would be greatly appreciated. Thanks.
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
Michael Chirlin
Appian Employee
over 12 years ago
Have you tried setting the cascade type to refresh?
@ManyToMany(cascade={CascadeType.REFRESH})
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
bend
over 12 years ago
Good advice Michael, it solved my issue. I also had to add nullable=true to the @JoinColumns to be able to add A and B records. Otherwise I received an error when inserting to the DB stating that I was missing the PK of the join table.
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel