Hi !
I have a Table "Cancion" and I want to get from MySQL DB a list of random "Cancion" objects, then after searching a little bit in documentation and community help, I used the following code :
Code:
IQuery sqlQuery = session.CreateSQLQuery("select {Cancion.*} from Cancion {Cancion} order by rand()", "Cancion", typeof(Cancion));
sqlQuery.SetMaxResults(limit);
cancion = (ArrayList)sqlQuery.List();
but I think this SQL is not portable for another DBMS (look here for random functions in other DBMS :
http://www.petefreitag.com/item/466.cfm), Do you know another way to make it portable ?
Sergio LópezHibernate version: 1.0.4 Mapping documents:Code:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0" namespace="TuMama" assembly="TuMama">
<class name="TuMama.Cancion" table="Cancion">
<id name="IdCancion" column="id_cancion" type="Int32" unsaved-value="0">
<generator class="native" />
</id>
<property name="Autor" column="autor" type="String" length="100"/>
<property name="Path" column="path" type="String" length="150"/>
<property name="Titulo" column="titulo" type="String" length="100"/>
</class>
</hibernate-mapping>
[/code]