SourceForge has been redesigned. Learn more.
Close

Virtual Entity backed from NamedQuery

webfrank
2013-09-24
2013-09-26
  • webfrank

    webfrank - 2013-09-24

    Hi,
    I would like to achive a simple dropdown (a @ManyToOne and
    @DescriptionsList) using an Entity not really stored on DB.

    I have a table like this:

     Comune
         codice char(9) PK
         descrizione varchar(255)
         provincia char(2)
    

    I have a normal Entity Comune and I would like to have a virtual Entity
    Provincia from a query like: SELECT DISTINCT provincia AS sigla FROM Comune

    This way I could use a @ManyToOne annotation with @DescriptionsList.

    Any suggestion?

    Francesco

     
  • Laurent Wibaux

    Laurent Wibaux - 2013-09-25

    Hi Francesco,

    I would definitively add one more table called Provincia. I would then make the provincia of Comune a Foreign key in your database schema.
    Then you naturally would have a @ManyToOne

    Laurent

     
  • Javier Paniza

    Javier Paniza - 2013-09-26

    Hi Francesco,

    I would follow the Laurent advice. However, if you have not the option of creating a new table, you can create a SQL VIEW and map it with a Provincia entity.


    Help others in this forum as I help you.
    Need more help? Get OpenXava professional support.

     

Log in to post a comment.