Created
October 25, 2012 20:05
-
-
Save gAmUssA/3955090 to your computer and use it in GitHub Desktop.
CompanyMapper and AssociateMapper for Oracle ClearDataBuilder sample
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.farata.example.mapper; | |
import java.util.List; | |
import org.apache.ibatis.annotations.Delete; | |
import org.apache.ibatis.annotations.Insert; | |
import org.apache.ibatis.annotations.Result; | |
import org.apache.ibatis.annotations.Results; | |
import org.apache.ibatis.annotations.Select; | |
import org.apache.ibatis.annotations.SelectKey; | |
import org.apache.ibatis.annotations.Update; | |
import com.farata.example.dto.AssociateDTO; | |
public interface AssociateMapper { | |
@Select("SELECT * FROM company_associate WHERE company_id = #{companyId}") | |
@Results(value = { @Result(property = "id", column = "id"), | |
@Result(property = "associateName", column = "associate"), | |
@Result(property = "companyId", column = "company_id") }) | |
List<AssociateDTO> getAssociates(Integer company_id); | |
@Insert("INSERT INTO company_associate (associate, company_id, id) VALUES (#{associateName}, #{companyId}, #{id})") | |
@SelectKey(statement = "select associate_id_seq.NEXTVAL from dual", keyProperty = "id", before = true, resultType = int.class) | |
Integer create(AssociateDTO dto); | |
@Update("UPDATE company_associate SET associate = #{associateName}, company_id = #{companyId} WHERE id = #{id}") | |
Integer update(AssociateDTO dto); | |
@Delete("DELETE FROM company_associate WHERE id = #{id}") | |
Integer delete(AssociateDTO dto); | |
} |
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.farata.example.mapper; | |
import java.util.List; | |
import org.apache.ibatis.annotations.Delete; | |
import org.apache.ibatis.annotations.Insert; | |
import org.apache.ibatis.annotations.Result; | |
import org.apache.ibatis.annotations.Results; | |
import org.apache.ibatis.annotations.Select; | |
import org.apache.ibatis.annotations.SelectKey; | |
import org.apache.ibatis.annotations.Update; | |
import com.farata.example.dto.CompanyDTO; | |
public interface CompanyMapper { | |
@Select("SELECT * FROM COMPANY") | |
@Results(value = { | |
@Result(property="id", column="id"), | |
@Result(property="companyName", column="company") | |
}) | |
List<CompanyDTO> getCompanies(); | |
@Insert("INSERT INTO COMPANY (company, id) VALUES (#{companyName}, #{id})") | |
@SelectKey(statement = "select company_id_seq.nextval from dual", keyProperty = "id", before = true, resultType = int.class) | |
Integer create(CompanyDTO dto); | |
@Update("UPDATE company SET company = #{companyName} WHERE id = #{id}") | |
Integer update(CompanyDTO dto); | |
@Delete("DELETE FROM company WHERE id = #{id}") | |
Integer delete(CompanyDTO dto); | |
@Delete("DELETE FROM company") | |
Integer deleteAll(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment