-->
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.  [ 5 posts ] 
Author Message
 Post subject: @Generated(Generation Time.INSERT I need your emergency help
PostPosted: Tue Mar 01, 2011 12:17 pm 
Newbie

Joined: Tue Mar 01, 2011 11:40 am
Posts: 3
Hi

I need your emergency help

I have a colun named "TK_I_MISPAR_TIK" that is not a primary key but is generated by a trigger and sequence at insert time
it look something like that:

@Entity
@Table(name = "PARK_TIKIM_IRUR", schema = "SCHEMA!", uniqueConstraints = {})
public class ParkTikimIrur implements java.io.Serializable {

@GenericGenerator(name = "generator", strategy = "com.ladpc.commons.database.sequence.LadpcSequeceGenerator", parameters = {
@Parameter(name = "schema", value = "SCHEMA!"),
@Parameter(name = "sequence", value = "PT_IRUR_TK_MIS_SIDURI_SEQ") })
@Id
@GeneratedValue(generator = "generator")
@Column(name = "TK_I_MIS_SIDURI", unique = true, nullable = false, precision = 15, scale = 0)
public Long getTkIMisSiduri() {
return this.tkIMisSiduri;
}

@Generated(GenerationTime.INSERT)
@Column(name = "TK_I_MISPAR_TIK" , nullable = false,insertable=false, updatable=false, precision = 15, scale = 0)
public Long getTkIMisparTik() {
return this.tkIMisparTik;
}

when i tried to retrieved the data i got a exception

java.lang.ClassCastException: java.lang.Integer
at org.hibernate.type.LongType.set(LongType.java:42)
at org.hibernate.type.NullableType.nullSafeSet(NullableType.java:136)
at org.hibernate.type.NullableType.nullSafeSet(NullableType.java:116)
at org.hibernate.loader.Loader.bindPositionalParameters(Loader.java:1707)
at org.hibernate.loader.Loader.bindParameterValues(Loader.java:1678)
at org.hibernate.loader.Loader.prepareQueryStatement(Loader.java:1563)
at org.hibernate.loader.Loader.doQuery(Loader.java:673)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:236)
at org.hibernate.loader.Loader.doList(Loader.java:2213)
at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2104)
at org.hibernate.loader.Loader.list(Loader.java:2099)
at org.hibernate.loader.criteria.CriteriaLoader.list(CriteriaLoader.java:94)
at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1569)
at org.hibernate.impl.CriteriaImpl.list(CriteriaImpl.java:283)
at org.hibernate.impl.CriteriaImpl.uniqueResult(CriteriaImpl.java:305)

it's seems like hibernate don't know that the type is Long and the inserted value that was 63 from the sequence
confusing hibernate to think that is of type Integer

Thank you for your emergency help

Yair


Top
 Profile  
 
 Post subject: Re: @Generated(Generation Time.INSERT I need your emergency help
PostPosted: Tue Mar 01, 2011 12:34 pm 
Expert
Expert

Joined: Thu Jan 08, 2009 6:16 am
Posts: 661
Location: Germany
Try attribute columnDefinition on you @Column-Annotation to match the DDL of the existing table.
Why don't you define the attribute as integer?

_________________
-----------------
Need advanced help? http://www.viada.eu


Top
 Profile  
 
 Post subject: Re: @Generated(Generation Time.INSERT I need your emergency help
PostPosted: Wed Mar 02, 2011 5:15 am 
Newbie

Joined: Tue Mar 01, 2011 11:40 am
Posts: 3
Hi

I'm using oracle so I add this columnDefinition = "NUMBER(15,0)"

@Generated(GenerationTime.INSERT)
@Column(name = "TK_I_MISPAR_TIK", columnDefinition = "NUMBER(15,0)" ,nullable = false,insertable=false, updatable=false, precision = 15, scale = 0)
public Long getTkIMisparTik() {
return this.tkIMisparTik;
}

But it was not help me
Do you have another Idea?
I need wide range for my misparTik so i can't use Integer

Thank you for your's replay

Yair


Top
 Profile  
 
 Post subject: Re: @Generated(Generation Time.INSERT I need your emergency help
PostPosted: Tue Mar 08, 2011 6:51 am 
Expert
Expert

Joined: Thu Jan 08, 2009 6:16 am
Posts: 661
Location: Germany
Please post the code, where you create the criteria. The stacktrace looks like you are setting a wrong type (Integer instead of Double) to a Restriction.

_________________
-----------------
Need advanced help? http://www.viada.eu


Top
 Profile  
 
 Post subject: Re: @Generated(Generation Time.INSERT I need your emergency help
PostPosted: Wed Mar 09, 2011 12:02 pm 
Newbie

Joined: Tue Mar 01, 2011 11:40 am
Posts: 3
THANK U!


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 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.