-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 
Author Message
 Post subject: urgent help needed !!! Thanks in advance
PostPosted: Tue Mar 15, 2005 1:52 am 
Newbie

Joined: Mon Mar 14, 2005 2:42 pm
Posts: 2
I have created a stored procedure :

CREATE OR REPLACE Procedure createCategory (catId In Number ,category IN VARCHAR2) IS

BEGIN

insert into Categories (Category_id,Category) values (catId,category) ;

END ;

///////////////////////////////////////////////////////////////////////////

My Configuration file looks like :
/////////////////////////////////////////////////////////////////////////////
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">

<hibernate-mapping
package="a"
default-access="field">
<class name="CategoriesDTO" table="Categories">
<id name="category_id">
<generator class="increment"/>
</id>
<property name="category" />
<sql-insert callable="true">{call createCategories (? , ?)}</sql-insert>
</class>
</hibernate-mapping>
/////////////////////////////////////////////////////////
Although table Categories has so many columns but i'm interested in inserting into category column.

/////////////////////////////////////////////////

I'm calling it using folowing sample class:

import org.hibernate.Session;
import org.hibernate.Query;
import org.hibernate.SessionFactory;
import a.CategoriesDTO;
import java.util.*;
import org.hibernate.connection.ConnectionProviderFactory;
import org.hibernate.connection.ConnectionProvider;
import java.sql.*;
import java.math.BigDecimal;
import org.hibernate.*;
import org.hibernate.cfg.Configuration;
import org.hibernate.Criteria;
import java.util.*;
import java.util.List;


public class HibernateSample {

public static void main(String[] args) throws Exception {

Configuration config = new Configuration();

// Mapping class
config.addClass(CategoriesDTO.class);

// Get the sesion factory we can use for persistence
SessionFactory sessionFactory = config.buildSessionFactory();

// Hibernate's Session
Session session = sessionFactory.openSession();

Transaction tx = null;
java.io.Serializable courseId ;


// Store a new Static Page in the database.
try
{
int tempId =12121212;
String str="test";

CategoriesDTO categories = new CategoriesDTO();

tx = session.beginTransaction();

categories.setCategory_id(tempId);

categories.setCategory(str);
session.save(categories);


tx.commit();

}
catch(Exception e){

e.printStackTrace();
}
finally
{

// Close our session and release resources
session.flush();
session.close();

}
sessionFactory.close();
}
}


////////////////////////////////////////////////////////////////////////////
getting the following error
/////////////////////////////////////////////////////////////////////////
org.hibernate.exception.GenericJDBCException: could not insert: [a.CategoriesDTO]
Caused by: java.sql.SQLException: ORA-06502: PL/SQL: numeric or value error: character to number conversion error
ORA-06512: at line 1




can some one help me out what is the issue with the above code....

thanks in advance


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 15, 2005 3:46 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
double posting is really not a good way to get help!

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject: REply
PostPosted: Tue Mar 15, 2005 7:40 am 
Newbie

Joined: Wed Feb 02, 2005 3:23 am
Posts: 1
I think you have to specify the type attribute for your category_id in your xml file


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 15, 2005 7:46 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
no that is not needed as hibernate will deduce it from the class file

_________________
Max
Don't forget to rate


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.