You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@openjpa.apache.org by Fernando Padilla <fe...@alum.mit.edu> on 2008/10/22 08:06:02 UTC

can I use Embedded objects in a query?

I have an object with an @Embedded sub object (which only contains a 
long as a sub field).  It looks to work just fine, except when I try to 
query the using that field.  You can see from the logs, that the JPQL 
query is OK (with correct parameter), yet the SQL it generates replaces 
the "this.ptTeamId = :p0" with "1 <> 1".  And it seems to do that for 
all queries involving Embedded objects ( of this variety at least )...

Any clues?  help?  hints?  ideas?? :) :)



LOGS:

DEBUG openjpa.Query - Executing query: [select this from 
com.protrade.fandom.data.entities.FbTeam this  where this.ptTeamId = 
:p0] with parameters: {p0=<<TeamId:Team:50306121>>}

DEBUG openjpa.jdbc.SQL - <t 19603027, conn 4242568> executing prepstmnt 
5520452 SELECT t0.JDOID, t0.CREATETIME, t0.AFFILIATION, t0.LEAGUE, 
t0.MASCOT, t0.PTTEAMID FROM FBTEAM t0 WHERE (1 <> 1)







@Entity
@Table(name = "FBTEAM")
public class FbTeam extends HBaseIdCreateTime {
....
@Embedded
@AttributeOverrides( { @AttributeOverride(name = "idLong", column = 
@Column(name = "PTTEAMID")) })
private TeamId ptTeamId;
....
}


@Embeddable
public class TeamId extends BaseProtradeId<Team> {
@Basic
private long idLong;
....
}