Created
August 22, 2012 08:58
-
-
Save luisartola/3423880 to your computer and use it in GitHub Desktop.
Ibatis Snippets - Building Inmutable Data Types
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.dnt.erleaTxingudi.ura.app; | |
public class BonificacionTotales { | |
protected String canon; | |
protected String bonificado; | |
public BonificacionTotales(String canon, String bonificado) { | |
this.canon = canon; | |
this.bonificado = bonificado; | |
} | |
@Override | |
public String toString() { | |
return canon + " " + bonificado; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<resultMap class="com.dnt.erleaTxingudi.ura.app.MutableBonificacionTotales" id="cocotero"> | |
<result property="canon" column="Consumo_SujetoBonificacion"/> | |
<result property="bonificado" column="Consumo_Bonificacion"/> | |
</resultMap> | |
<select id="retrieveResumenUraMetrosTotalesBonificados" resultMap="cocotero" parameterClass="map"> | |
</select> | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.dnt.erleaTxingudi.ura.app; | |
public class MutableBonificacionTotales extends BonificacionTotales { | |
/* | |
1 - por desgracia hay que añadir este constructor guarro para que compile | |
e ibatis sea capaz de hacer su mierda java beans | |
2 - la alternativa sería que esta clase NO extendiera BonificacionTotales, | |
duplicar los atributos de clase, y hacer el mapping a mano. | |
*/ | |
public MutableBonificacionTotales() { | |
super(null, null); | |
} | |
public void setCanon(String canon) { | |
this.canon = canon; | |
} | |
public void setBonificado(String bonificado) { | |
this.bonificado = bonificado; | |
} | |
public BonificacionTotales blindar() { | |
return (BonificacionTotales) this; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Lo * peor * de todo es que tendría que llamar a entity.blindar() al recuperar cada elemento MutableXXX de una List<>.