bladepit
bladepit

Reputation: 873

No Dialect mapping for JDBC type: -102

i have a problem. Some sql in my program could be written by the user. So I don't know which table or which columns are in this sql. Therefore i want to detect which column names are in the sql. But if a date is in the sql i get the No Dialect mapping for JDBC type: -102 error. How could i handle that? I am using hibernate 3.6 or 4.1.3 with java. My database is an oracle database. The dialect is org.hibernate.dialect.Oracle10gDialect.

I really don't know what is in the sql.

Here is my code:

SQLQuery q=session.createSQLQuery("SELECT * FROM tbl WHERE id = 2"); 
q.setResultTransformer(AliasToEntityMapResultTransformer.INSTANCE); 
List<Map<String,Object>> aliasToValueMapList=q.list();
for(Map<String,Object> map : aliasToValueMapList){
    System.out.println(map.keySet());
    break;
}

I hope anyone knows a solution for this problem.

Greetz

Upvotes: 1

Views: 2321

Answers (2)

Steve Ebersole
Steve Ebersole

Reputation: 9443

Your query is attempt to return a column that the JDBC ResultSetMetaData is reporting a type (-102) which Hibernate does not know how to read. You need to register the type for that column with the query using org.hibernate.SQLQuery#addScalar or you may not be able to use that transformer and actually define the entire result set mapping to your entity org.hibernate.SQLQuery#addRoot/org.hibernate.SQLQuery#addEntity. See the docs for usage

Upvotes: 3

Karesh A
Karesh A

Reputation: 1751

If you use session.createQuery() this will use your dialect to talk to the database using Hibernate Query Language. but if you use createSQLQuery() you have to use PL/SQL to talk to the oracle.

Upvotes: 1

Related Questions