Java 如何使用log4j查看hibernate子选择查询?

Java 如何使用log4j查看hibernate子选择查询?,java,hibernate,jpa,logging,log4j,Java,Hibernate,Jpa,Logging,Log4j,我正在使用persistence-api-1.0和hibernate-annotations-3.4.0.GA。我有一辆汽车,定义如下: @Entity(name = "CarEntity") @Table(name = "CAR") @NamedQuery(name = CarEntity.Queries.BY_IDS.NAME, query = CarEntity.Queries.BY_IDS.TEXT) public class CarEntity { @Id

我正在使用
persistence-api-1.0
hibernate-annotations-3.4.0.GA
。我有一辆
汽车
,定义如下:

@Entity(name = "CarEntity")
@Table(name = "CAR")
@NamedQuery(name = CarEntity.Queries.BY_IDS.NAME, query = CarEntity.Queries.BY_IDS.TEXT)

 public class CarEntity
    {
      @Id
      @Column(name = "CAR_ID", nullable = false, insertable = false, updatable = false)
      private long carId;

      @OneToMany(fetch = FetchType.EAGER, mappedBy = "car", cascade = CascadeType.ALL)
      @Fetch(FetchMode.SUBSELECT)
      private Collection<CarComponentEntity> components= new ArrayList<CarComponentEntity>();  

      public Collection<CarComponentEntity> getComponents()
      {
        return components;
      }

        public static interface Queries
       {
         interface BY_IDS
         {
            String NAME = "CarEntity.ByIDs";
            String TEXT = "select component from CarEntity component where component.id in (:ids)";
            String PARAMETER_CAR_IDS = "ids";
         }
       }
    }  
我的问题是,由于
CarComponent
不是
Car
上的一列,反之亦然,因此在构造获取
CarEntity
的查询时,如何填充
CarComponentEntity
集合?更重要的是,我如何看待该查询

此外,我没有使用Spring或hibernate xml文件


谢谢。

log4j不是显示sql语句吗?@Sandhu-不是,它只显示从Car表中选择的sql,因为CarComponent不是Car表的一部分,所以我看不到它。
 log4j.rootLogger = WARN, standard  
    log4j.logger.org.hibernate.SQL=DEBUG  
    log4j.logger.org.hibernate.trace=TRACE  
    log4j.logger.org.hibernate.type = TRACE