Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[eclipselink-users] Needless join on simple select?

Hi,

I've got question about queries generated by EclipseLink. Here are my
mappings:

@Entity
@Inheritance(strategy=InheritanceType.JOINED)
public class ContentContainer {

}

@Entity
public class Category extends ContentContainer {

}

@Entity
public class Message {

  @ManyToOne(fetch=FetchType.LAZY,optional=false)
  ContentContainer container;
}


When i'm executing a query for Message:

select m from Message m where m.container.id=:containerId order by
m.creationDate desc

Following SQL has been generated by eclipselink:

SELECT t0.ID AS ID1, t0.[..columns from t0...], t0.CONTAINER_ID AS
CONTAINER_ID9 FROM message t0, content_container t1 WHERE ((t1.ID = ?) AND
(t1.ID = t0.CONTAINER_ID)) ORDER BY t0.CREATIONDATE DESC

Why there is a join on content_container table? There are no columns
selected from t1 table. I think it should be something like that:

SELECT t0.ID AS ID1, t0.[..columns from t0...], t0.CONTAINER_ID AS
CONTAINER_ID9 FROM message t0 WHERE (t0.CONTAINER_ID=?) ORDER BY
t0.CREATIONDATE DESC

I'm using EclipseLink 2.0-M2.1

--
Best regards,
Marek Kaluzny
-- 
View this message in context: http://www.nabble.com/Needless-join-on-simple-select--tp23319813p23319813.html
Sent from the EclipseLink - Users mailing list archive at Nabble.com.



Back to the top