# Mapping JPA entities As out parameters using hibernate

**URL:** <https://discourse.hibernate.org/t/mapping-jpa-entities-as-out-parameters-using-hibernate/9934>\
**Category:** Hibernate ORM\
**Created:** [July 11, 2024, 9:12pm UTC](https://discourse.hibernate.org/t/mapping-jpa-entities-as-out-parameters-using-hibernate/9934 "2024-07-11T21:12:39Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Clara](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.hibernate.org/clara/32/3353_2.png) [@Clara](https://discourse.hibernate.org/u/Clara)\
**Post date:** [July 11, 2024, 9:12pm UTC](https://discourse.hibernate.org/t/mapping-jpa-entities-as-out-parameters-using-hibernate/9934/1 "2024-07-11T21:12:39Z")

</div>

Hi , I have a stored procedure as follows

```auto
CREATE OR REPLACE PACKAGE BODY Pkg_name
IS

PROCEDURE proceure_Name (
Id IN Long,
startDate IN DATE,
EndDate IN DATE,

Table1 OUT Table1_Name%ROWTYPE,
Table2 OUT Table2_Name%ROWTYPE,
errormsg OUT VARCHAR2)
IS

Record another_Table%ROWTYPE;

```

I am using my test class to call this procedure  
@Test  
public void procedure9\_2() throws ParseException, HibernateException {

```
    SessionFactory sessionFactory = this.getEntityManager().unwrap(Session.class).getSessionFactory();
    EntityManager em = sessionFactory.createEntityManager();
    Long id = 417478732001288L;
    Date startDate = setDateTime("08/31/2023 00:00:00");
    Date endDate = setDateTime("09/01/2018 00:00:00");
  

    String errorMsg = null;
    try (Session session = sessionFactory.openSession()) {
        session.getTransaction().begin();
        ProcedureCall call = session
                .createStoredProcedureCall("package_name.procedure_name");

        call.registerParameter(1, Long.class, ParameterMode.IN);
        call.registerParameter(2, Date.class, ParameterMode.IN);
        call.registerParameter(3, Date.class, ParameterMode.IN);
        call.registerParameter(4, Table1_Name.class, ParameterMode.OUT);
        call.registerParameter(5, Table1_Name.class, ParameterMode.OUT);
        call.registerParameter(6, String.class, ParameterMode.OUT);
        call.setParameter(1, id);
        call.setParameter(2, startDate);
        call.setParameter(3, startDate);

        System.out.println(call.getOutputs());

```

}

when I execute this I am getting  
PLS-00306: wrong number or types of arguments in call to ‘procedure\_name’  
ORA-06550: line 1, column 7:  
PLS-00306: wrong number or types of arguments in call to ‘procedure\_name’  
ORA-06550: line 1, column 7:  
PL/SQL: Statement ignored  
Not sure where am I going wrong ☹  
Pleasee helpp !

---

<div class="post-metadata">

**Author:** ![mbladel](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.hibernate.org/mbladel/32/2128_2.png) [@mbladel](https://discourse.hibernate.org/u/mbladel)\
**Post date:** [July 12, 2024, 7:36am UTC](https://discourse.hibernate.org/t/mapping-jpa-entities-as-out-parameters-using-hibernate/9934/2 "2024-07-12T07:36:14Z")

</div>

Hello, from the code you pasted it’s not clear what `Table1_Name.class` is but if that’s an entity, it’s not supported as an output stored procedure parameter type. You can look at Hibernate’s [OutputableType](https://github.com/hibernate/hibernate-orm/blob/1e4b9e8ffb8aeee024faa2160f3e79019564e424/hibernate-core/src/main/java/org/hibernate/query/OutputableType.java#L25) interface to understand what’s supported as an output parameter for procedure calls, but basically it’s only basic types and components which are mapped as [aggregates](https://in.relation.to/2023/02/13/hibernate-orm-62-composite-aggregates/) via `@Struct`.

---

<div class="post-metadata">

**Author:** ![Clara](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.hibernate.org/clara/32/3353_2.png) [@Clara](https://discourse.hibernate.org/u/Clara)\
**Post date:** [July 12, 2024, 3:38pm UTC](https://discourse.hibernate.org/t/mapping-jpa-entities-as-out-parameters-using-hibernate/9934/3 "2024-07-12T15:38:58Z")

</div>

yes you are right , it is an entity . So if my entity is as follows , there is no way I an map it as a parameter type ?

@Entity  
@IdGeneratedBy15Digit  
@Table(name=“Table\_name”)

public class tableName extends BaseEntity {

```
/** The id. */
@Id
@FieldBusinessName("Id")
@Column(name = "ID", unique = true, precision = 15)
private Long id;

```
