Tree structure handling by MyBatis

Hello, 

I've got a table that maps to itself. I tried to construct correct 
mapping file but I was unsuccessful and ended up with exception 
### Cause: java.sql.SQLException: ORA-00900: invalid SQL statement 
; bad SQL grammar []; nested exception is java.sql.SQLException: 
ORA-00900: invalid SQL statement 

Is there any possibility to do such a mapping? 

My files: 

<?xml version="1.0" encoding="UTF-8" ?> 
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http:// 
mybatis.org/dtd/mybatis-3-mapper.dtd"> 
<mapper namespace="package_name.mappers.PeriodMapper"> 
        <resultMap id="periodResultMap" type="package_name.Period"> 
                <id property="id" column="id_period"/> 
                <result property="periodname" column="name"/> 
                <result property="kod" column="code"/> 
                <result property="begdate" column="begdate"/> 
                <result property="enddate" column="enddate"/> 
                <result property="flag" column="flag"/> 
                <association property="parent" column="par_id_period" 
resultMap="periodResuiltMap" select="selectPeriod"/> 
        </resultMap> 
        <select id="selectPeriod" parameterType="Long" 
resultMap="periodResultMap"> 
        SELECT * FROM period WHERE id_period = #{id} 
        </select> 
</mapper> 

CREATE TABLE period 
    (id_period                      NUMBER NOT NULL, 
    periodname                     VARCHAR2(255), 
    kod                            VARCHAR2(8), 
    par_id_period                  NUMBER, 
    begdate                        DATE, 
    enddate                        DATE, 
    flag                           VARCHAR2(2)) 
and bean: 

public class Period { 
    private Long id; 
    private String name; 
    private String code; 
    private Period parent; 
    private Date begDate; 
    private Date endDate; 
    public enum Flag { 
                Y, Q, M 
        } 
    private Flag flag; 
    get... set... 


Thanks, 
Andrew 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值