About Question enthuware.oce-jpad.v6.2.414 :
Moderators: Site Manager, fjwalraven
-
- Posts: 18
- Joined: Sun Jun 21, 2015 2:56 am
- Contact:
About Question enthuware.oce-jpad.v6.2.414 :
Hello,
I think the explanation for the third option: "the value of joinColumns must be @JoinColumns or @JoinColumn" is invalid, because joinColumns is defines as JoinColumn[].
I think the explanation for the third option: "the value of joinColumns must be @JoinColumns or @JoinColumn" is invalid, because joinColumns is defines as JoinColumn[].
-
- Site Admin
- Posts: 10064
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.oce-jpad.v6.2.414 :
You can use @JoinColumn also if there is only one.
If you like our products and services, please help us by posting your review here.
-
- Posts: 18
- Joined: Sun Jun 21, 2015 2:56 am
- Contact:
Re: About Question enthuware.oce-jpad.v6.2.414 :
You're right, but what I meant is the "JoinColumns" annotation - the grouping annotation which can consist of several @JoinColumn definitions.
-
- Site Admin
- Posts: 10064
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.oce-jpad.v6.2.414 :
You can annotate like this:
joinColumns=@JoinColumn(name="EV_2")
or
joinColumns=@JoinColumns({
@JoinColumn(name="DEPT_NAME", referencedColumnName="Name"),
@JoinColumn(name="DEPT_ID", referencedColumnName="ID")
})
Both are valid. That is why the explanation says that the value of joinColumns can be @JoinColumn or JoinColumns
HTH,
Paul.
joinColumns=@JoinColumn(name="EV_2")
or
joinColumns=@JoinColumns({
@JoinColumn(name="DEPT_NAME", referencedColumnName="Name"),
@JoinColumn(name="DEPT_ID", referencedColumnName="ID")
})
Both are valid. That is why the explanation says that the value of joinColumns can be @JoinColumn or JoinColumns
HTH,
Paul.
If you like our products and services, please help us by posting your review here.
-
- Posts: 18
- Joined: Sun Jun 21, 2015 2:56 am
- Contact:
Re: About Question enthuware.oce-jpad.v6.2.414 :
The first case works perfectly, but the second does not compile:
"Error:(45, 28) java: incompatible types: javax.persistence.JoinColumns cannot be converted to javax.persistence.JoinColumn"
Examples:
"Error:(45, 28) java: incompatible types: javax.persistence.JoinColumns cannot be converted to javax.persistence.JoinColumn"
Examples:
Code: Select all
@Entity
@DiscriminatorValue("QP")
@AssociationOverride(
name = "employees", joinColumns = @JoinColumns({
@JoinColumn(name = "FK_EMP")
})
)
public class QualityProject extends Project {
...
}
Code: Select all
@ElementCollection(targetClass = VacationEntry.class)
@CollectionTable(name = "VACATIONS",
joinColumns = @JoinColumns({@JoinColumn(name = "EMP_ID")}))
@AttributeOverride(name = "daysTaken",
column = @Column(name = "DAYS_ABS"))
private Collection vacationBookings;
-
- Site Admin
- Posts: 10064
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.oce-jpad.v6.2.414 :
Not sure why it is not working, but you can see the example of @JoinColumns at
http://docs.oracle.com/javaee/7/api/jav ... lumns.html
http://docs.oracle.com/javaee/7/api/jav ... lumns.html
Code: Select all
@JoinColumns({
@JoinColumn(name="ADDR_ID", referencedColumnName="ID"),
@JoinColumn(name="ADDR_ZIP", referencedColumnName="ZIP")
})
If you like our products and services, please help us by posting your review here.
-
- Posts: 18
- Joined: Sun Jun 21, 2015 2:56 am
- Contact:
Re: About Question enthuware.oce-jpad.v6.2.414 :
This example is for using @JoinColumns alone, not as a value of "joinColumns" property of @AssociationOverride.
Code for full example:
Code for full example:
Code: Select all
@ManyToOne
@JoinColumns({
@JoinColumn(name="ADDR_ID", referencedColumnName="ID"),
@JoinColumn(name="ADDR_ZIP", referencedColumnName="ZIP")
})
public Address getAddress() { return address; }
-
- Site Admin
- Posts: 10064
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.oce-jpad.v6.2.414 :
I tried looking for an example of joinColumns property but couldn't find any. But I think you are right. I have updated the explanation.
thank you for your feedback!
Paul.
thank you for your feedback!
Paul.
If you like our products and services, please help us by posting your review here.
Who is online
Users browsing this forum: No registered users and 62 guests