Isn't your select statement only returning distinct profil values. You need to include the id and droits columns in order for your config to work.
Z. > > I have a problem while using complex properties. Here is my code : > > <resultMap id="Utilisateur.map" > class="Utilisateur.classe"> > <result property="id" column="id" /> > <result property="login" column="login"/> > <result property="password" column="password"/> > <result property="nom" column="nom"/> > <result property="prenom" column="prenom"/> > <result property="dateCreation" column="dateCreation"/> > <result property="dateLastModif" column="dateLastModif"/> > <result property="dateLastConnec" column="dateLastConnec"/> > <result property="idEan" column="idEan" select="Ean.getOne"/> > <result property="idProfil" column="idProfil" > select="ProfilUtilisateur.getOne"/> > <result property="idLangue" column="idLangue" select="Langue.getOne"/> > </resultMap> > > <resultMap id="ProfilUtilisateur.map" class="ProfilUtilisateur.classe"> > <result property="id" column="id"/> > <result property="profil" column="profil"/> > <result property="droits" column="droits"/> > </resultMap> > > <select id="ProfilUtilisateur.getOne" resultMap="ProfilUtilisateur.map"> > SELECT id, profil, droits > FROM profilutilisateur > WHERE id=#value# > </select> > > <select id="Utilisateur.getAllProfils" resultMap="ProfilUtilisateur.map" > parameterClass="Utilisateur.classe"> > SELECT DISTINCT(idProfil) > FROM utilisateur > <dynamic prepend="WHERE"> > <isNotEmpty prepend="AND" property="idEan"> > idEan=#idEan.id# > </isNotEmpty> > <isNotEmpty prepend="AND" property="dateCreation"> > DATE_FORMAT(dateCreation,'%Y')=DATE_FORMAT(#dateCreation#,'%Y') > </isNotEmpty> > </dynamic> > </select> > > While using Utilisateur.getAllProfils i get this error : > SqlMapClient operation; bad SQL grammar []; nested exception is > com.ibatis.common.jdbc.exception.NestedSQLException: --- The error occurred > in profilsutilisateurs-mysql.xml. --- The error occurred while applying a > result map. --- Check the ProfilUtilisateur.map. --- Check the result > mapping for the 'id' property. --- Cause: java.sql.SQLException: Column 'id' > not found. Caused by: java.sql.SQLException: Column 'id' not found. > > I really don't know what is the problem. Please help me.
