-->
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.  [ 14 posts ] 
Author Message
 Post subject: [Hb 3.1a/PgSQL] operator does not exist: character varying
PostPosted: Mon Jul 04, 2005 6:07 am 
Newbie

Joined: Tue Oct 26, 2004 4:21 am
Posts: 10
Location: Belgium
Hi, I'm trying to migrate from HSQLDB Default Datasource on JBoss 4.0.3rc1 to a Postgresql DB.

When using my app on HSQLDB, no problem. When trying to use pgSql Datasource, got this error:

java.sql.SQLException: ERROR: operator does not exist: character varying = bytea

(see exception stack trace)

You will see I'm using a UserEnumType (enhanced version posted in wiki) to persit an enum called 'userGroup'.

To terminate, here is my query and 'create table' pg script:

// GroupEnum group;
list = (List<User>) em.createQuery("from User where userGroup = :group").setParameter("group", group).getResultList();

CREATE TABLE users -- GENERATED BY HIBERNATE
(
id int8 NOT NULL,
disabled bool NOT NULL,
"password" varchar(32),
username varchar(32),
firstconnection timestamp,
lastconnection timestamp,
usergroup varchar(20),
person_id int8,
CONSTRAINT users_pkey PRIMARY KEY (id),
CONSTRAINT fk4d495e8e149448b FOREIGN KEY (person_id) REFERENCES person (id) ON UPDATE NO ACTION ON DELETE NO ACTION,
CONSTRAINT users_username_key UNIQUE (username)
)
WITH OIDS;

Any idea?
Thx,
Renaud

----------------

Hibernate version: 3.1alpha [JBoss 4.0.3RC1 w/EJB3]

Mapping documents:

package be.sysmedit.model.core.app;

import java.io.Serializable;
import java.util.Date;
import java.util.HashSet;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratorType;
import javax.persistence.Id;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Transient;

import org.apache.commons.lang.builder.HashCodeBuilder;
import org.apache.commons.lang.builder.ToStringBuilder;
import org.hibernate.annotations.Parameter;
import org.hibernate.annotations.Type;
import org.hibernate.annotations.TypeDef;
import org.hibernate.annotations.TypeDefs;

import be.sysmedit.model.core.Person;
import be.sysmedit.model.itrequest.Request;
import be.sysmedit.persistence.types.EnumUserType;

/**
* Represents the application user.
*
* @todo Ajouter une spécialisation ItUser dans .model.itrequest et transférer
* watches
*/
@TypeDefs( {
@TypeDef(name = "group", typeClass = EnumUserType.class, parameters = {
@Parameter(name = "enumClassName", value = "be.sysmedit.model.core.app.GroupEnum")
})
})
@Entity
// Needed by postgresql since it's a reserved word and hibernate don't care:
@Table (name = "USERS")
public class User implements Serializable {
private Long id;

private String userName;

private String password;

private boolean disabled;

private Date firstConnection;

private Date lastConnection;

private GroupEnum userGroup;

public Person person;

public Set<Request> requestWatches = new HashSet<Request>();

public User() {
}

public User(String userName, String password) {
this.userName = userName;
this.password = password;
this.disabled = false;
this.firstConnection = this.lastConnection = new Date();
}

public User(String userName, String password, GroupEnum userGroup) {
this.userName = userName;
this.password = password;
this.userGroup = userGroup;
this.disabled = false;
this.firstConnection = this.lastConnection = new Date();
}

@Id(generate = GeneratorType.AUTO)
public Long getId() {
return id;
}

private void setId(Long id) {
this.id = id;
}

@Column(length = 32, unique = true)
public String getUserName() {
return userName;
}

public void setUserName(String userName) {
this.userName = userName;
}

@Column(length = 32)
public String getPassword() {
return password;
}

public void setPassword(String password) {
this.password = password;
}

public boolean isDisabled() {
return disabled;
}

public void setDisabled(boolean disabled) {
this.disabled = disabled;
}

public Date getFirstConnection() {
return firstConnection;
}

public void setFirstConnection(Date firstConnection) {
this.firstConnection = firstConnection;
}

public Date getLastConnection() {
return lastConnection;
}

public void setLastConnection(Date lastConnection) {
this.lastConnection = lastConnection;
}

@ManyToOne(fetch = FetchType.EAGER, cascade = { CascadeType.PERSIST,
CascadeType.MERGE, CascadeType.REFRESH })
public Person getPerson() {
return person;
}

public void setPerson(Person person) {
this.person = person;
}

@Type(type = "group")
@Column(length = 20)
public GroupEnum getUserGroup() {
return userGroup;
}

public void setUserGroup(GroupEnum userGroup) {
this.userGroup = userGroup;
}

/**
* Promouvoit ou dégrade un utilisateur. Pour ce faire, l'utilisateur source
* doit avoir au moins les droits qu'il tente d'attribuer
*
* @todo considérer le cas de la dégradation (source doit avoir au moins les
* droits de l'utilisateur)
* @param source
* Utilisateur à l'origine du changement
* @param promotion
* Nouveau groupe
*/
@Transient
public void promoteUser(User source, GroupEnum promotion)
throws AccessRightsViolationException {
if (source.getUserGroup().compareTo(promotion) >= 0) { // La source
// doit avoir au
// moins les
// droits de la
// promotion
this.userGroup = promotion;
} else {
throw new AccessRightsViolationException("User "
+ source.getUserName() + " can't promote with " + promotion);
}
}

@ManyToMany(fetch = FetchType.LAZY, cascade = { CascadeType.ALL }, mappedBy = "userWatches")
public Set<Request> getRequestWatches() {
return requestWatches;
}

public void setRequestWatches(Set<Request> requestWatches) {
this.requestWatches = requestWatches;
}

@Transient
public void addRequestWatch(Request request) {
if (!this.requestWatches.contains(request)) {
this.requestWatches.add(request);
request.addWatch(this);
}
}

@Transient
public void removeRequestWatch(Request request) {
requestWatches.remove(request);
request.removeWatch(this);
}

@Transient
public boolean isWatching(Request request) {
return this.requestWatches.contains(request);
}

@Transient
public boolean isPromotable() {
return (userGroup.isItAdmin() || userGroup.isItUser());
}

@Transient
public boolean isDegradable() {
return (userGroup.isItAdmin() || userGroup.isSuperUser());
}

@Transient
public void promote() {
if (userGroup.isItAdmin())
userGroup = GroupEnum.SUPERUSER;
else if (userGroup.isItUser())
userGroup = GroupEnum.ITREQUEST_ADMIN;
}

@Transient
public void degrade() {
if (userGroup.isItAdmin())
userGroup = GroupEnum.ITREQUEST_USER;
else if (userGroup.isSuperUser())
userGroup = GroupEnum.ITREQUEST_ADMIN;
}

@Override
public int hashCode() {
if (id != null) {
return new HashCodeBuilder().append(id).toHashCode();
} else {
return super.hashCode();
}
}

@Override
@Transient
public String toString() {
return new ToStringBuilder(this).append("userName", userName).append(
"disabled", disabled).toString();
}

@Override
@Transient
public boolean equals(Object o) {
if (o instanceof User) {
User user = (User) o;
return (id != null) ? id.equals(user.getId())
: super.equals(o);
}
return false;
}

@Transient
public int compareTo(Object obj) {
User user = (User) obj;
return this.userName.compareTo(user.getUserName());
}
}

Code between sessionFactory.openSession() and session.close():

N/A

Full stack trace of any exception that occurs:

_Exception:_
javax.ejb.EJBTransactionRolledbackException: null; CausedByException is:
could not execute query
at org.jboss.ejb3.tx.Ejb3TxPolicy.handleInCallerTx(Ejb3TxPolicy.java:65)
at org.jboss.aspects.tx.TxPolicy.invokeInCallerTx(TxPolicy.java:117)
at org.jboss.aspects.tx.TxInterceptor$Required.invoke(TxInterceptor.java:138)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:88)
at org.jboss.aspects.tx.TxPropagationInterceptor.invoke(TxPropagationInterceptor.java:72)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:88)
at org.jboss.ejb3.stateless.StatelessInstanceInterceptor.invoke(StatelessInstanceInterceptor.java:39)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:88)
at org.jboss.aspects.security.AuthenticationInterceptor.invoke(AuthenticationInterceptor.java:63)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:88)
at org.jboss.ejb3.asynchronous.AsynchronousInterceptor.invoke(AsynchronousInterceptor.java:93)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:88)
at org.jboss.ejb3.stateless.StatelessContainer.localInvoke(StatelessContainer.java:148)
at org.jboss.ejb3.stateless.StatelessLocalProxy.invoke(StatelessLocalProxy.java:65)
at $Proxy82.findByGroup(Unknown Source)
at be.sysmedit.services.itrequest.ApplicationServiceBean.checkAdmin(ApplicationServiceBean.java:249)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:99)
at org.jboss.ejb3.AllowedOperationsInterceptor.invoke(AllowedOperationsInterceptor.java:33)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:88)
at org.jboss.aspects.tx.TxPolicy.invokeInOurTx(TxPolicy.java:66)
at org.jboss.aspects.tx.TxInterceptor$Required.invoke(TxInterceptor.java:134)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:88)
at org.jboss.aspects.tx.TxPropagationInterceptor.invoke(TxPropagationInterceptor.java:72)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:88)
at org.jboss.ejb3.stateless.StatelessInstanceInterceptor.invoke(StatelessInstanceInterceptor.java:39)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:88)
at org.jboss.aspects.security.AuthenticationInterceptor.invoke(AuthenticationInterceptor.java:63)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:88)
at org.jboss.ejb3.asynchronous.AsynchronousInterceptor.invoke(AsynchronousInterceptor.java:93)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:88)
at org.jboss.ejb3.stateless.StatelessContainer.dynamicInvoke(StatelessContainer.java:183)
at org.jboss.aop.Dispatcher.invoke(Dispatcher.java:107)
at org.jboss.aspects.remoting.IsLocalInterceptor.invoke(IsLocalInterceptor.java:30)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:88)
at org.jboss.ejb3.stateless.StatelessRemoteProxy.invoke(StatelessRemoteProxy.java:79)
at $Proxy94.checkAdmin(Unknown Source)
at be.sysmedit.web.admin.ApplicationBean.verifySetup(ApplicationBean.java:50)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.apache.myfaces.el.MethodBindingImpl.invoke(MethodBindingImpl.java:138)
at oracle.adf.view.faces.component.UIXComponentBase.__broadcast(UIXComponentBase.java:1097)
at oracle.adf.view.faces.component.UIXCommand.broadcast(UIXCommand.java:204)
at javax.faces.component.UIViewRoot._broadcastForPhase(UIViewRoot.java:110)
at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:184)
at org.apache.myfaces.lifecycle.LifecycleImpl.invokeApplication(LifecycleImpl.java:271)
at org.apache.myfaces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:102)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:109)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at oracle.adfinternal.view.faces.webapp.AdfFacesFilterImpl._doFilterImpl(AdfFacesFilterImpl.java:310)
at oracle.adfinternal.view.faces.webapp.AdfFacesFilterImpl.doFilter(AdfFacesFilterImpl.java:183)
at oracle.adf.view.faces.webapp.AdfFacesFilter.doFilter(AdfFacesFilter.java:87)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:81)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
at org.jboss.web.tomcat.security.CustomPrincipalValve.invoke(CustomPrincipalValve.java:39)
at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:153)
at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:59)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:856)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:744)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
at org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:112)
at java.lang.Thread.run(Thread.java:595)
org.hibernate.exception.SQLGrammarException: could not execute query
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:59)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
at org.hibernate.loader.Loader.doList(Loader.java:1861)
at org.hibernate.loader.Loader.list(Loader.java:1842)
at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:407)
at org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:273)
at org.hibernate.impl.SessionImpl.list(SessionImpl.java:850)
at org.hibernate.impl.QueryImpl.list(QueryImpl.java:74)
at org.hibernate.ejb.QueryImpl.getResultList(QueryImpl.java:41)
at be.sysmedit.persistence.core.app.UserDAOBean.findByGroup(UserDAOBean.java:109)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:99)
at org.jboss.ejb3.AllowedOperationsInterceptor.invoke(AllowedOperationsInterceptor.java:33)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:88)
at org.jboss.aspects.tx.TxPolicy.invokeInCallerTx(TxPolicy.java:113)
at org.jboss.aspects.tx.TxInterceptor$Required.invoke(TxInterceptor.java:138)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:88)
at org.jboss.aspects.tx.TxPropagationInterceptor.invoke(TxPropagationInterceptor.java:72)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:88)
at org.jboss.ejb3.stateless.StatelessInstanceInterceptor.invoke(StatelessInstanceInterceptor.java:39)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:88)
at org.jboss.aspects.security.AuthenticationInterceptor.invoke(AuthenticationInterceptor.java:63)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:88)
at org.jboss.ejb3.asynchronous.AsynchronousInterceptor.invoke(AsynchronousInterceptor.java:93)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:88)
at org.jboss.ejb3.stateless.StatelessContainer.localInvoke(StatelessContainer.java:148)
at org.jboss.ejb3.stateless.StatelessLocalProxy.invoke(StatelessLocalProxy.java:65)
at $Proxy82.findByGroup(Unknown Source)
at be.sysmedit.services.itrequest.ApplicationServiceBean.checkAdmin(ApplicationServiceBean.java:249)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:99)
at org.jboss.ejb3.AllowedOperationsInterceptor.invoke(AllowedOperationsInterceptor.java:33)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:88)
at org.jboss.aspects.tx.TxPolicy.invokeInOurTx(TxPolicy.java:66)
at org.jboss.aspects.tx.TxInterceptor$Required.invoke(TxInterceptor.java:134)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:88)
at org.jboss.aspects.tx.TxPropagationInterceptor.invoke(TxPropagationInterceptor.java:72)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:88)
at org.jboss.ejb3.stateless.StatelessInstanceInterceptor.invoke(StatelessInstanceInterceptor.java:39)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:88)
at org.jboss.aspects.security.AuthenticationInterceptor.invoke(AuthenticationInterceptor.java:63)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:88)
at org.jboss.ejb3.asynchronous.AsynchronousInterceptor.invoke(AsynchronousInterceptor.java:93)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:88)
at org.jboss.ejb3.stateless.StatelessContainer.dynamicInvoke(StatelessContainer.java:183)
at org.jboss.aop.Dispatcher.invoke(Dispatcher.java:107)
at org.jboss.aspects.remoting.IsLocalInterceptor.invoke(IsLocalInterceptor.java:30)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:88)
at org.jboss.ejb3.stateless.StatelessRemoteProxy.invoke(StatelessRemoteProxy.java:79)
at $Proxy94.checkAdmin(Unknown Source)
at be.sysmedit.web.admin.ApplicationBean.verifySetup(ApplicationBean.java:50)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.apache.myfaces.el.MethodBindingImpl.invoke(MethodBindingImpl.java:138)
at oracle.adf.view.faces.component.UIXComponentBase.__broadcast(UIXComponentBase.java:1097)
at oracle.adf.view.faces.component.UIXCommand.broadcast(UIXCommand.java:204)
at javax.faces.component.UIViewRoot._broadcastForPhase(UIViewRoot.java:110)
at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:184)
at org.apache.myfaces.lifecycle.LifecycleImpl.invokeApplication(LifecycleImpl.java:271)
at org.apache.myfaces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:102)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:109)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at oracle.adfinternal.view.faces.webapp.AdfFacesFilterImpl._doFilterImpl(AdfFacesFilterImpl.java:310)
at oracle.adfinternal.view.faces.webapp.AdfFacesFilterImpl.doFilter(AdfFacesFilterImpl.java:183)
at oracle.adf.view.faces.webapp.AdfFacesFilter.doFilter(AdfFacesFilter.java:87)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:81)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
at org.jboss.web.tomcat.security.CustomPrincipalValve.invoke(CustomPrincipalValve.java:39)
at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:153)
at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:59)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:856)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:744)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
at org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:112)
at java.lang.Thread.run(Thread.java:595)
Caused by: java.sql.SQLException: ERROR: operator does not exist: character varying = bytea
at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:1471)
at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1256)
at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:175)
at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:389)
at org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdbc2Statement.java:330)
at org.postgresql.jdbc2.AbstractJdbc2Statement.executeQuery(AbstractJdbc2Statement.java:240)
at org.jboss.resource.adapter.jdbc.WrappedPreparedStatement.executeQuery(WrappedPreparedStatement.java:296)
at org.hibernate.jdbc.AbstractBatcher.getResultSet(AbstractBatcher.java:120)
at org.hibernate.loader.Loader.getResultSet(Loader.java:1537)
at org.hibernate.loader.Loader.doQuery(Loader.java:638)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:221)
at org.hibernate.loader.Loader.doList(Loader.java:1858)
... 90 more

Name and version of the database you are using:

PostgreSQL 8.0.3

The generated SQL (show_sql=true):

select user0_.id as id, user0_.disabled as disabled3_, user0_.password as password3_, user0_.userName as userName3_, user0_.firstConnection as firstCon5_3_, user0_.lastConnection as lastConn6_3_, user0_.person_id as person8_3_, user0_.userGroup as userGroup3_ from USERS user0_ where user0_.userGroup=?

Debug level Hibernate log excerpt:

---


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jul 06, 2005 3:40 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
I've added out of the box support for enums in the last annotations version. Try it out

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jul 07, 2005 4:00 am 
Newbie

Joined: Tue Oct 26, 2004 4:21 am
Posts: 10
Location: Belgium
Aaah! Wonderful :) Thanks.

And do you think it can be deployed directly under JBoss4.0.3RC1?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jul 07, 2005 4:25 am 
Newbie

Joined: Tue Oct 26, 2004 4:21 am
Posts: 10
Location: Belgium
OK. I bet it was the deployed version on JBoss4.0.3rc1, but removed the Type[Def]s and it looks better.

Yet had some exceptions:

CREATE SQL:
----------------
CREATE TABLE users
(
id int8 NOT NULL,
disabled bool NOT NULL,
"password" varchar(32),
username varchar(32),
firstconnection timestamp,
lastconnection timestamp,
usergroup int4,
person_id int8,
CONSTRAINT users_pkey PRIMARY KEY (id),
CONSTRAINT fk4d495e8e149448b FOREIGN KEY (person_id) REFERENCES person (id) ON UPDATE NO ACTION ON DELETE NO ACTION,
CONSTRAINT users_username_key UNIQUE (username)
)
WITH OIDS;

QUERY (the same):
------------------------
// GroupEnum group
list = (List<User>) em.createQuery("from User where userGroup = :group").setParameter("group", group).getResultList();

SQL:
-----
Hibernate: select user0_.id as id, user0_.disabled as disabled3_, user0_.password as password3_, user0_.userName as userName3_, user0_.firstConnection as firstCon5_3_, user0_.lastConnection as lastConn6_3_, user0_.person_id as person8_3_, user0_.userGroup as userGroup3_ from USERS user0_ where user0_.userGroup=?

LOG:
-----
WARN org.hibernate.util.JDBCExceptionReporter - SQL Error: 0, SQLState: 42883
ERROR org.hibernate.util.JDBCExceptionReporter - operator does not exist: integer = bytea


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jul 10, 2005 12:25 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
Hum weird, I have tested on Postgres and it was working fine.
Open a JIRA issue with a runnable test case, I'll check that

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jul 13, 2005 8:22 am 
Newbie

Joined: Tue Oct 26, 2004 4:21 am
Posts: 10
Location: Belgium
emmanuel wrote:
Hum weird, I have tested on Postgres and it was working fine.
Open a JIRA issue with a runnable test case, I'll check that


Maybe the GroupEnum class could help you?

Seems to be an issue during the mapping of the 'group' into the query... The message "ERROR: operator does not exist: integer = bytea" seems to indicate that the userGroup column is correctly set to int4 but the compared value is interpreted as a 'bytea' type.

Can't it be possible there is a failure with the EnumUserType when getting the type 'Integer' of an enumeration, during a query?

If you really want to, I could create an exemple of this issue, but I think all the elements of the problem are there?

---

public enum GroupEnum implements Serializable {
SUPERUSER (0, "Super User"),
ITREQUEST_ADMIN (100, "IT Admin"),
ITREQUEST_USER (110, "IT User");

private String friendlyName;
private int level;

private GroupEnum(int level, String name) {
this.level = level;
this.friendlyName = name;
}

public boolean isSuperUser() {
return this == SUPERUSER;
}

public boolean isItAdmin() {
return this == ITREQUEST_ADMIN;
}

public boolean isItUser() {
return this == ITREQUEST_USER;
}

public int getLevel() {
return level;
}

public void setLevel(int level) {
this.level = level;
}

public String getFriendlyName() {
return friendlyName;
}

public void setFriendlyName(String friendlyName) {
this.friendlyName = friendlyName;
}

public static GroupEnum getByLevel(int level) {
for (GroupEnum grp : values()) {
if (grp.getLevel() == level)
return grp;
}
return null;
}
}


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jul 13, 2005 11:18 am 
Newbie

Joined: Tue Oct 26, 2004 4:21 am
Posts: 10
Location: Belgium
Opened a JIRA Issue on
http://opensource.atlassian.com/project ... wse/ANN-47

Thanks,
Renaud


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jul 13, 2005 12:12 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
Emmanuel, this is not for JIRA. User is using some stuff he pulled off the wiki, not your "official" enum support.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jul 13, 2005 1:07 pm 
Newbie

Joined: Tue Oct 26, 2004 4:21 am
Posts: 10
Location: Belgium
gavin wrote:
Emmanuel, this is not for JIRA. User is using some stuff he pulled off the wiki, not your "official" enum support.


Sorry if I'm not clear. I removed dependencies on my own implementation of EnumUserType.

The exception i'm talking about and I put on JIRA is about hibernate-annotations.jar's implementation (EnumType).

The Schema export is correct (Integer under HSQLDB, int4 under PgSQL) but I can't execute a query with an enum into a where statement: JBoss/Hibernate seems to try to compare an Integer with an Object (abyte under pgSQL).

Cannot find the solution about this issue...


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jul 13, 2005 1:15 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
I supose the problem is that when you called setParameter("group", group) you did not specify a Type, so Hibernate guessed "serializable".


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jul 14, 2005 4:56 am 
Newbie

Joined: Tue Oct 26, 2004 4:21 am
Posts: 10
Location: Belgium
gavin wrote:
I supose the problem is that when you called setParameter("group", group) you did not specify a Type, so Hibernate guessed "serializable".


Hello Gavin,

* I observe that there is no need to specify a Type for anyone of the basic java types and they are not assumed "Serializable" object by Hibernate. So If java5 enums does, it is a bug.

* I cannot find the way to specify the Hibernate Type in the interface javax.persistence.Query (I'm using EJB3), through the EntityManager.

* Anyway, if you look at the example I attached to the JIRA bug you closed, you will see I also try using HibernateSession.getHibernateSession() object, and calling setParameter(String, Object, Type) with Type = org.hibernate.type.EnumType. It fails too.

Regards,
Renaud


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jul 14, 2005 6:48 am 
Newbie

Joined: Tue Oct 26, 2004 4:21 am
Posts: 10
Location: Belgium
OK, I was using the hibernate query badly, and now I found a workaround, but as we say in french, "c'est pas le pied" ;)

First, I was not able to use an EntityManager Query even using a @TypeDef annotation on EnumType like this (example from JIRA)

Code:
@TypeDefs(
       {
       @TypeDef(
           name="gender",
           typeClass = EnumType.class,
           parameters = {
               @Parameter(name="enumClass", value="testpgsql.Gender")
           }
       )
       }
   )
...
@Type (type="gender")
public Gender getGender() {...}


So I used this workaround:

Code:
HibernateSession hs = (HibernateSession) em;
Session session = hs.getHibernateSession();
return (List<Person>) session.createQuery("from Person where gender = :gender")
    .setParameter("gender", gender, Hibernate.custom(EnumType.class, new String[]{"enumClass"}, new String[]{Gender.class.getName()}))
    .list();


Anyway, I suppose the EnumType, as implemented in hibernate-annotations, is not recognized yet by the hibernate query engine, and interpret as Serializable, so, no way to compare an integer with a bytearray.

Maybe will this be fixed in future versions of EJB3? :))

Good bye and thank you for your help,
Renaud


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jul 14, 2005 1:41 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
Note that you could just do something like:

Code:
query.setParameter("paramName", enumValue.name())


or

Code:
query.setParameter("paramName", enumValue.ordinal())


Which is much less verbose.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jul 14, 2005 2:24 pm 
Newbie

Joined: Tue Oct 26, 2004 4:21 am
Posts: 10
Location: Belgium
gavin wrote:
Note that you could just do something like:

Code:
query.setParameter("paramName", enumValue.name())


or

Code:
query.setParameter("paramName", enumValue.ordinal())


Which is much less verbose.


:)
I could do that


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