-->
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: MappingException with @Transient annotation
PostPosted: Thu Mar 03, 2005 9:41 pm 
Senior
Senior

Joined: Tue Mar 02, 2004 6:17 pm
Posts: 151
I ran into yet another confusing exception message when using annotations.

org.hibernate.MappingException: property mapping has wrong number of columns: com.be.desktopbeautifier.server.CataloguedContentType.canonicalInstance type: object
com.be.desktopbeautifier.servlet.DefaultServlet.init(DefaultServlet.java:51)
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:526)
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:825)
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:738)
org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:526)
org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
java.lang.Thread.run(Unknown Source)

I think this is coming from:

@Transient()
public CataloguedContentType getCanonicalInstance(Session session)

which overrides:

@Transient()
public Object getCanonicalInstance(Session session);

Now, seeing how the property is declared @Transient I don't understand this exception. Furthermore, it looks like Hibernate is tripping over the covariant return types. It seems to be picking up the return type of the superclass instead of the subclass.

Ideas?

Gili


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 04, 2005 3:23 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
Please post a runnable testcase in JIRA, I'll have a look.

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 04, 2005 3:24 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
covariant overriding does not make much sens in the ER model.

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 04, 2005 3:36 pm 
Senior
Senior

Joined: Tue Mar 02, 2004 6:17 pm
Posts: 151
emmanuel wrote:
covariant overriding does not make much sens in the ER model.


I do not understand why not. I mean.... could you elaborate?


Top
 Profile  
 
 Post subject:
PostPosted: Sat Mar 05, 2005 4:56 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
Basically an association is an FK in the DB, there is no polymorphism of FK in an entity relational model

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Sun Mar 06, 2005 1:35 am 
Senior
Senior

Joined: Tue Mar 02, 2004 6:17 pm
Posts: 151
emmanuel wrote:
Basically an association is an FK in the DB, there is no polymorphism of FK in an entity relational model


Ok, so in the above case, where I am trying to session.saveOrUpdate() on a subclass, does Hibernate pick up the subclass property type or the superclass property? I never persist the superclass.

As well, in the above case I think I was getting that exception simply trying to initialize a AnnotationConfiguration (i.e. no persisting at all). Does it pick up the superclass or subclass return-type in that case?

Gili


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 08, 2005 11:23 pm 
Senior
Senior

Joined: Tue Mar 02, 2004 6:17 pm
Posts: 151
Emmanuel,

Something else is wrong. I don't think this is related to covariants but something is seriously b0rked.

Here is a minimal testcase. Please try it on your end and tell me what (if anything) I'm doing wrong. I don't understand the error message . . . is it possible to clarify it further?

----
HibernateObject.java

package com.be.desktopbeautifier.server;

import javax.ejb.GeneratorType;
import javax.ejb.Id;
import javax.ejb.Transient;
import javax.ejb.Version;
import org.hibernate.Session;

/**
* All objects persisted by Hibernate should implement this interface.
*
* @author Gili Tzabari
*/
public interface HibernateObject<Type>
{
/**
* Returns the object ID.
*/
@Id(generate=GeneratorType.AUTO)
public int getId();

/**
* Returns the object version (used for optimistic database locking).
*/
@Version()
public int getVersion();

/**
* Returns the canonical instance of this object. Often, this involves
* searching the database for a preexisting copy of the object and returning
* it. If no match is found, the current instance is returned.
*
* @param session Hibernate session associated with object
*/
@Transient()
public Type getCanonicalInstance(Session session);
}

-----

-----
Dummy.java

package com.be.desktopbeautifier.server;

import javax.ejb.Entity;
import javax.ejb.GeneratorType;
import javax.ejb.Id;
import javax.ejb.Table;
import javax.ejb.Transient;
import javax.ejb.Version;

interface MyInterface extends HibernateObject<MyInterface>
{}

@Entity()
@Table(name="dummy")
public class Dummy implements MyInterface
{
@Transient()
public MyInterface getCanonicalInstance(org.hibernate.Session session)
{
return null;
}

@Id(generate=GeneratorType.AUTO)
public int getId()
{
return 0;
}

@Version()
public int getVersion()
{
return 0;
}
}
------

------
Hibernate.cfg.xml

<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">

<hibernate-configuration>
<session-factory>
<mapping package="com.be.desktopbeautifier.server"/>
<mapping class="com.be.desktopbeautifier.server.Dummy"/>
</session-factory>
</hibernate-configuration>

------

When I run new "AnnotationConfiguration().configure().buildSessionFactory()" I get:

property mapping has wrong number of columns: com.be.desktopbeautifier.server.Dummy.canonicalInstance type: object

which makes absolutely no sense to me. What does it mean by "wrong number of columns"? canonicalInstance is a transient property so talking about columns makes no sense :(

I'd like to file a JIRA bug report against this but I'm unsure what to put in the summary field because this isn't a problem with covariants anymore. It looks like a problem with @Transient. Please confirm.

Thanks,
Gili


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 10, 2005 9:34 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
put it on JIRA anyway, That's the only place I'll not forgot it.
Set the title to "Generics usage in interfaces".

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 10, 2005 12:38 pm 
Senior
Senior

Joined: Tue Mar 02, 2004 6:17 pm
Posts: 151
emmanuel wrote:
put it on JIRA anyway, That's the only place I'll not forgot it.
Set the title to "Generics usage in interfaces".


Already filed here http://opensource.atlassian.com/project ... se/HBX-134 under a different name. Feel free to update the title.


Top
 Profile  
 
 Post subject:
PostPosted: Sat Mar 19, 2005 8:32 pm 
Senior
Senior

Joined: Tue Mar 02, 2004 6:17 pm
Posts: 151
cowwoc wrote:
emmanuel wrote:
put it on JIRA anyway, That's the only place I'll not forgot it.
Set the title to "Generics usage in interfaces".


Already filed here http://opensource.atlassian.com/project ... se/HBX-134 under a different name. Feel free to update the title.


Emmanuel, this issue is a showstopper for me so I would really appreciate it if you took a look and at least let me know if there is a workaround for it. If you have any problems reproducing it let me know and I will get back to you as soon as possible.

Thanks,
Gili


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 25, 2005 12:38 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
Hi Gili
Sorry for the delay.
I'm working hard on the Early draft 2 compatibility. After that, I'll be able to review the opened JIRA issues.

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 25, 2005 4:40 pm 
Senior
Senior

Joined: Tue Mar 02, 2004 6:17 pm
Posts: 151
emmanuel wrote:
Hi Gili
Sorry for the delay.
I'm working hard on the Early draft 2 compatibility. After that, I'll be able to review the opened JIRA issues.


I can't tell you how glad I am you finally replied. My flagship product is blocked on this issue and I'm running out of auxilary projects to work on :)

No pressure intended, but if you had to roughly estimate when you'll get around to the opened JIRA issues, when do you think that'll happen? Are we talking one month? less? more?

Thanks,
Gili


Top
 Profile  
 
 Post subject:
PostPosted: Sat Mar 26, 2005 5:24 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
I think I'll start looking at JIRA after the end of next week

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Mon Apr 18, 2005 1:45 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
This should now work.
Can you test it from CVS (needs hibernate 3.0.1, wait for sf.net CVS to be in sync - max 24 h)?

_________________
Emmanuel


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.