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.  [ 2 posts ] 
Author Message
 Post subject: could not set a field value by reflection
PostPosted: Tue May 19, 2009 9:51 am 
Newbie

Joined: Tue May 19, 2009 9:28 am
Posts: 2
Hi!

i have a problem with fields in database type char(*)

In my firebird database fields of type char(2) and char(9), i'm trying to mapping them in my entities.

example:

Code:
public class Endereco implements Serializable {
...

     @Column(name = "ESTADO") 
     @Type(type="character") 
     private String estado; 
       
     @Column(name = "CEP") 
     @Type(type="character") 
     private String cep;


...

public String getEstado() {
   return estado;
}

public void setEstado(String estado) {
    this.estado = estado;
}

public String getCep() {
   return cep;
}

public void setCep(String cep) {
    this.cep = cep;
}
}


when i use @Type(type="character") returns a propertyexception:
Quote:
could not set a field value by reflection setter of br.com.theos.client.database.entities.Endereco.cep


and when not use @Type return error:
Quote:
Wrong column type: CEP, expected: varchar(255)


looking this post: http://blogs.warwick.ac.uk/colinyates/e ... hibernate/
i updated all fields null to '88888-888' and and still the same error

also tried to change the type to char[] :(

I do not use persistence.xml, AnnotationConfiguration am using to connect to the bank and mapping of classes.
Sample: http://www.edmafer.com.br/?p=230

another attempt to define the type:
Code:
@TypeDef(typeClass=org.hibernate.type.CharacterArrayType.class, name="mchartype")

and
Code:
@Type(type="mchartype")


but return Wrong column...


Top
 Profile  
 
 Post subject: Re: could not set a field value by reflection
PostPosted: Tue May 19, 2009 1:32 pm 
Newbie

Joined: Tue May 19, 2009 9:28 am
Posts: 2
Solved!

Missing this property
Code:
@Column(name = "ESTADO", columnDefinition="char(2)")


and removed the annotation @Type


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