OK. I think i figured it out. I was assuming that OpenJPA would be
smart enough to figure out relationships to other entities (as kodo used
to do). But it looks like to fix this I have to explicitly add:
@ManyToOne
@JoinColumn(name = "FAN_JDOID")
private Fan fan;
Very annoying having to go through my whole data model and fill those
in, but at least better than the alternative of it not working at all! :)
So anyone have any shortcuts, so that OpenJPA would just make a
ManyToOne assumption? possibly?
Fernando Padilla wrote:
> thank you for replying!
>
> Fan and TeamFan are entities of course. They extend a MappedSuperclass.
> Here are the four classes involved in this query. Fan and TeamFan
> extend HBaseIdCreateTime, which extends HBaseId.
>
> And just to recap from last email:
>
> I load a "Fan" object via the "fbId" field, and that works just fine.
> Then I try to load a "TeamFan" object via that "Fan" object just loaded,
> and a "teamId". But it complains that the Fan is not a valid type:
>
> <openjpa-1.2.0-r422266:683325 nonfatal user error>
> org.apache.openjpa.persistence.ArgumentException: The specified
> parameter of type "class com.protrade.fandom.data.entities.Fan" is not a
> valid query parameter.
>
>
>
>
>
>
>
> @Entity
> @Table(name = "TEAMFAN")
> public class TeamFan extends HBaseIdCreateTime {
> @Column(name = "FAN_JDOID")
> private Fan fan;
>
> @Column(name = "TEAMID")
> @Externalizer("getIdLong")
> private FbTeamId teamId;
> .....
>
>
> @Entity
> @Table(name = "FAN")
> public class Fan extends HBaseIdCreateTime implements UnifiedSocialUser{
> @Column(name = "BEBOID")
> private Long beboId;
> @Column(name = "FBID")
> private Long fbId;
> @Column(name = "HI5ID")
> private String hi5Id;
> @Column(name = "MOSID")
> private String mosId;
> .....
>
>
> @MappedSuperclass
> public class HBaseIdCreateTime extends HBaseId implements
> BaseIdCreateTime {
> @Basic
> @Column(name = "CREATETIME")
> private long createTime;
> .....
>
>
> @MappedSuperclass
> public class HBaseId extends BaseObject implements BaseId, Serializable{
> @Id
> @Column(name = "JDOID")
> @GeneratedValue
> private Long id;
>
> @Version
> @Column(name = "JDOVERSION")
> private long jdoversion;
> .....
>
>
>
> Jeremy Bauer wrote:
>> Hi Fernando,
>>
>> Is TeamFan also defined as an entity and is there an inheritance
>> strategy defined for the Fan - TeamFan hierarchy? If not, you'll need
>> to make sure you have a valid JPA inheritance hierarchy & strategy.
>> If this is the case, could you post your entity classes or even
>> better, a failing test case?
>>
>> -Jeremy
|