0

i need to build a sql query that returns a bean with inside an entity... i try to explain me with an example.

This is my bean that i want to get from the query:

public class EventiPerGiorno { 

    private Eventi evento; // THIS IS AN ENTITY
    private Date primoSpettacolo; //SCALAR
    private int spettacoli; //SCALAR
...
}

and this is the xml query mapping:

<sql-query name="eventiPerGiorno">
    <return alias="evento" class="entity.Eventi"/>
    <return-scalar column="spettacoli" type="integer"/>
    <return-scalar column="primoSpettacolo" type="date"/>
    <![CDATA[
        select 
            spettacoli.evento as {evento.id},
            count(spettacoli.id) as spettacoli,
            min(spettacoli.inizio) as primoSpettacolo,
        from ...
    ]]>
</sql-query>

But Hibernate says to me that it want ALL properties of Eventi in the select not only the primary key that is "evento.id". Why?

4

0 回答 0