Elliott
Elliott

Reputation: 5609

Error occurring in Hibernate when join column is String

I have two tables that I want to join using hibernate. The join column, as represented in my model is a String (its a varchar(10) in my database). When I run the HQL query, what I see is the following error, "conversion failed when converting the varchar value 'AS00' to data type int. "AS500" is the first value of join column in the first row.

I do not know why hibernate is doing this. My join column is not an int. I have checked both models corresponding to my tables and they are both defined as Strings. Is there some kind of restriction on the data types that can be used for join columns?

Upvotes: 0

Views: 370

Answers (1)

bradleyfitz
bradleyfitz

Reputation: 691

Please post both your model and the hql query.

If I had to take a guess (and that's all any of us can do without specifics), I would say that your hql query does not use .setParameter and it does not have single quotes around the string value in your query... so it is trying to implicitly convert the value to int.

Example that would cause this error:

Query query = session.createQuery("from Person where name = bob");

Upvotes: 1

Related Questions