How to map OracleSet

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

How to map OracleSet

Almir Abrarov
@Mapper
@Qualifier("BrandMapper")
public interface BrandMapper {
    @Select("{CALL #{out, jdbcType=CURSOR, javaType=java.sql.ResultSet, mode=OUT, resultMap=Brand} := pkg_Car.getBrand}")
   
@Options(statementType = StatementType.CALLABLE)

   
@Results(id = "Brand", value = {
           
@Result(property = "brandId", column = "car_brand_id"),
            @Result(property = "brandName", column = "car_brand_name"),
            @Result(property = "isForeign", column = "is_foreign"),
    })
    List<Brand> getAll();
Hello! This code doesnt work: "Cause: org.apache.ibatis.reflection.ReflectionException: There is no setter for property named 'out' in 'class java.lang.Class'"


@AllArgsConstructor(access = AccessLevel.PUBLIC)
@NoArgsConstructor
public class Brand {
   
@Getter @Setter private Integer brandId;
    @Getter @Setter private String brandName;
    @Getter @Setter private Integer isForeign;


}

function getBrand (
  brandId in integer := null
  )
return sys_refcursor
is
  rc sys_refcursor;

--
You received this message because you are subscribed to the Google Groups "mybatis-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: How to map OracleSet

Erwan Letessier
Hi
Although the Oracle function returns something, on Mybatis side the method actually returns void for any callable statement.
"out" is the name of the pointer to the List<Brand> result. Then you have to pass a parameter to the mapper method. Type Map or anything with a property named "out" in this case.
Since latest release you may pass a ResultHandler  (probably instead of param) allowing to process directly the results instead of fetching them all in a temporary list.

Cheers 


On Wed, Apr 4, 2018, 16:17 Almir Abrarov <[hidden email]> wrote:
@Mapper
@Qualifier("BrandMapper")
public interface BrandMapper {
    @Select("{CALL #{out, jdbcType=CURSOR, javaType=java.sql.ResultSet, mode=OUT, resultMap=Brand} := pkg_Car.getBrand}")
   
@Options(statementType = StatementType.CALLABLE)

   
@Results(id = "Brand", value = {
           
@Result(property = "brandId", column = "car_brand_id"),
            @Result(property = "brandName", column = "car_brand_name"),
            @Result(property = "isForeign", column = "is_foreign"),
    })
    List<Brand> getAll();
Hello! This code doesnt work: "Cause: org.apache.ibatis.reflection.ReflectionException: There is no setter for property named 'out' in 'class java.lang.Class'"


@AllArgsConstructor(access = AccessLevel.PUBLIC)
@NoArgsConstructor
public class Brand {
   
@Getter @Setter private Integer brandId;
    @Getter @Setter private String brandName;
    @Getter @Setter private Integer isForeign;


}

function getBrand (
  brandId in integer := null
  )
return sys_refcursor
is
  rc sys_refcursor;

--
You received this message because you are subscribed to the Google Groups "mybatis-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "mybatis-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: How to map OracleSet

Almir Abrarov
If I use this constuction

void getAllBrand(@Param("out")

then I get:
nested exception is org.apache.ibatis.executor.ExecutorException: No constructor found in void matching [java.math.BigDecimal, java.lang.String, java.math.BigDecimal]

but I have record with Integer, String, Integer


среда, 4 апреля 2018 г., 21:10:45 UTC+3 пользователь Erwan Letessier написал:
Hi
Although the Oracle function returns something, on Mybatis side the method actually returns void for any callable statement.
"out" is the name of the pointer to the List<Brand> result. Then you have to pass a parameter to the mapper method. Type Map or anything with a property named "out" in this case.
Since latest release you may pass a ResultHandler  (probably instead of param) allowing to process directly the results instead of fetching them all in a temporary list.

Cheers 


On Wed, Apr 4, 2018, 16:17 Almir Abrarov <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="welGZ5l9CAAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">almir....@...> wrote:
@Mapper
@Qualifier("BrandMapper")
public interface BrandMapper {
    @Select("{CALL #{out, jdbcType=CURSOR, javaType=java.sql.ResultSet, mode=OUT, resultMap=Brand} := pkg_Car.getBrand}")
   
@Options(statementType = StatementType.CALLABLE)

   
@Results(id = "Brand", value = {
           
@Result(property = "brandId", column = "car_brand_id"),
            @Result(property = "brandName", column = "car_brand_name"),
            @Result(property = "isForeign", column = "is_foreign"),
    })
    List<Brand> getAll();
Hello! This code doesnt work: "Cause: org.apache.ibatis.reflection.ReflectionException: There is no setter for property named 'out' in 'class java.lang.Class'"


@AllArgsConstructor(access = AccessLevel.PUBLIC)
@NoArgsConstructor
public class Brand {
   
@Getter @Setter private Integer brandId;
    @Getter @Setter private String brandName;
    @Getter @Setter private Integer isForeign;


}

function getBrand (
  brandId in integer := null
  )
return sys_refcursor
is
  rc sys_refcursor;

--
You received this message because you are subscribed to the Google Groups "mybatis-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to <a href="javascript:" rel="nofollow" target="_blank" gdf-obfuscated-mailto="welGZ5l9CAAJ" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">mybatis-user...@googlegroups.com.
For more options, visit <a href="https://groups.google.com/d/optout" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;">https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "mybatis-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: How to map OracleSet

Erwan Letessier
The param is there to carry the pointer to the List<Brand> result.
Named parameter map is then not enough. I guess the target is still not detected. That is why attempting to use the method type (Void) to set results fields.
So the call must be like:
Map params = new HashMap ();
mapper.getAllBrand ();
List<Brand> result = map.get ("out");

If it doesn't work then maybe functions doesn't work the way I thought and you may try with Oracle procedure with an out cursor param.

On Thu, Apr 5, 2018, 14:03 Almir Abrarov <[hidden email]> wrote:
If I use this constuction

void getAllBrand(@Param("out")

then I get:
nested exception is org.apache.ibatis.executor.ExecutorException: No constructor found in void matching [java.math.BigDecimal, java.lang.String, java.math.BigDecimal]

but I have record with Integer, String, Integer


среда, 4 апреля 2018 г., 21:10:45 UTC+3 пользователь Erwan Letessier написал:
Hi
Although the Oracle function returns something, on Mybatis side the method actually returns void for any callable statement.
"out" is the name of the pointer to the List<Brand> result. Then you have to pass a parameter to the mapper method. Type Map or anything with a property named "out" in this case.
Since latest release you may pass a ResultHandler  (probably instead of param) allowing to process directly the results instead of fetching them all in a temporary list.

Cheers 


On Wed, Apr 4, 2018, 16:17 Almir Abrarov <[hidden email]> wrote:
@Mapper
@Qualifier("BrandMapper")
public interface BrandMapper {
    @Select("{CALL #{out, jdbcType=CURSOR, javaType=java.sql.ResultSet, mode=OUT, resultMap=Brand} := pkg_Car.getBrand}")
   
@Options(statementType = StatementType.CALLABLE)

   
@Results(id = "Brand", value = {
           
@Result(property = "brandId", column = "car_brand_id"),
            @Result(property = "brandName", column = "car_brand_name"),
            @Result(property = "isForeign", column = "is_foreign"),
    })
    List<Brand> getAll();
Hello! This code doesnt work: "Cause: org.apache.ibatis.reflection.ReflectionException: There is no setter for property named 'out' in 'class java.lang.Class'"


@AllArgsConstructor(access = AccessLevel.PUBLIC)
@NoArgsConstructor
public class Brand {
   
@Getter @Setter private Integer brandId;
    @Getter @Setter private String brandName;
    @Getter @Setter private Integer isForeign;


}

function getBrand (
  brandId in integer := null
  )
return sys_refcursor
is
  rc sys_refcursor;

--
You received this message because you are subscribed to the Google Groups "mybatis-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "mybatis-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "mybatis-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re[2]: How to map OracleSet

Guy Rouillier-2
In reply to this post by Almir Abrarov
Take a look at the refcursor sample that comes with the MyBatis source code.  It has an example of using a stored function to return a refcursor.

--
Guy Rouillier

------ Original Message ------
From: "Almir Abrarov" <[hidden email]>
To: "mybatis-user" <[hidden email]>
Sent: 4/5/2018 8:03:26 AM
Subject: Re: How to map OracleSet

If I use this constuction

void getAllBrand(@Param("out")

then I get:
nested exception is org.apache.ibatis.executor.ExecutorException: No constructor found in void matching [java.math.BigDecimal, java.lang.String, java.math.BigDecimal]

but I have record with Integer, String, Integer


среда, 4 апреля 2018 г., 21:10:45 UTC+3 пользователь Erwan Letessier написал:
Hi
Although the Oracle function returns something, on Mybatis side the method actually returns void for any callable statement.
"out" is the name of the pointer to the List<Brand> result. Then you have to pass a parameter to the mapper method. Type Map or anything with a property named "out" in this case.
Since latest release you may pass a ResultHandler  (probably instead of param) allowing to process directly the results instead of fetching them all in a temporary list.

Cheers 


On Wed, Apr 4, 2018, 16:17 Almir Abrarov <[hidden email]> wrote:
@Mapper
@Qualifier("BrandMapper")
public interface BrandMapper {
    @Select("{CALL #{out, jdbcType=CURSOR, javaType=java.sql.ResultSet, mode=OUT, resultMap=Brand} := pkg_Car.getBrand}")
   
@Options(statementType = StatementType.CALLABLE)

   
@Results(id = "Brand", value = {
           
@Result(property = "brandId", column = "car_brand_id"),
            @Result(property = "brandName", column = "car_brand_name"),
            @Result(property = "isForeign", column = "is_foreign"),
    })
    List<Brand> getAll();
Hello! This code doesnt work: "Cause: org.apache.ibatis.reflection.ReflectionException: There is no setter for property named 'out' in 'class java.lang.Class'"


@AllArgsConstructor(access = AccessLevel.PUBLIC)
@NoArgsConstructor
public class Brand {
   
@Getter @Setter private Integer brandId;
    @Getter @Setter private String brandName;
    @Getter @Setter private Integer isForeign;


}

function getBrand (
  brandId in integer := null
  )
return sys_refcursor
is
  rc sys_refcursor;

--
You received this message because you are subscribed to the Google Groups "mybatis-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mybatis-user...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "mybatis-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "mybatis-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.