New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

java.lang.StackOverflowError on recursive generic type #264

Closed
Ghalleb opened this Issue Nov 2, 2012 · 6 comments

Comments

Projects
None yet
2 participants
@Ghalleb

Ghalleb commented Nov 2, 2012

Hi,

When initializing a query, I have a java.lang.StackOverflowError error.

It seems that I have a recursive loop on init.

The stack tells us:

...
Caused by: java.lang.StackOverflowError
at com.mysema.query.types.HashCodeVisitor.visit(HashCodeVisitor.java:38)
at com.mysema.query.types.HashCodeVisitor.visit(HashCodeVisitor.java:10)
at com.mysema.query.types.PathImpl.accept(PathImpl.java:93)
at com.mysema.query.types.ExpressionBase.hashCode(ExpressionBase.java:47)
at com.mysema.query.types.expr.DslExpression.hashCode(DslExpression.java:68)
at java.util.Arrays.hashCode(Arrays.java:3655)
at com.google.common.base.Objects.hashCode(Objects.java:70)
at com.mysema.query.types.PathMetadata.(PathMetadata.java:45)
at com.mysema.query.types.PathMetadataFactory.forProperty(PathMetadataFactory.java:112)
at com.mysema.query.types.path.BeanPath.forProperty(BeanPath.java:302)
at com.mysema.query.types.path.BeanPath.createNumber(BeanPath.java:249)
at com.test.QCommonEntity.(QCommonEntity.java:21)
at com.test.QLocalizableEntity.(QLocalizableEntity.java:21)
at com.test.QCommonOrganizationalUnit.(QCommonOrganizationalUnit.java:23)
at com.test.QCommonOrganizationalUnit.(QCommonOrganizationalUnit.java:68)
at com.test.QCommonOrganizationalUnit.(QCommonOrganizationalUnit.java:63)
at com.test.QCommonOrganizationalUnit.(QCommonOrganizationalUnit.java:40)
at com.test.QCommonOrganizationalUnit.(QCommonOrganizationalUnit.java:68)
at com.test.QCommonOrganizationalUnit.(QCommonOrganizationalUnit.java:63)
at com.test.QCommonOrganizationalUnit.(QCommonOrganizationalUnit.java:40)
...

My Object look like:

public abstract class CommonOrganizationalUnit<T extends EntityLocalized, E extends TenantPreference, P extends CommonOrganizationalUnit<?, ?, ?>> 
extends LocalizableEntity<T> 
implements Serializable, IComposite, Comparable<CommonOrganizationalUnit<T, E, P>> {

private P parent;

@Override
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "parentid")
public P getParent() {
    return parent;
}
…
}

I have no Warning on code generation, the problem occurs on runtime

@timowest

This comment has been minimized.

Show comment
Hide comment
@timowest

timowest Nov 2, 2012

Member

Could you confirm that you get the same error with only the parent property in the entity class?

Member

timowest commented Nov 2, 2012

Could you confirm that you get the same error with only the parent property in the entity class?

@Ghalleb

This comment has been minimized.

Show comment
Hide comment
@Ghalleb

Ghalleb Nov 2, 2012

Parent really seems to be the problem.

To avoid the problem, I use the @QueryType(PropertyType.NONE) annotation on it and use the _super to acces the parent.

Ghalleb commented Nov 2, 2012

Parent really seems to be the problem.

To avoid the problem, I use the @QueryType(PropertyType.NONE) annotation on it and use the _super to acces the parent.

@timowest

This comment has been minimized.

Show comment
Hide comment
@timowest

timowest Nov 2, 2012

Member

Could you also provide the references classes? Otherwise I can't reproduce the problem.

Member

timowest commented Nov 2, 2012

Could you also provide the references classes? Otherwise I can't reproduce the problem.

@Ghalleb

This comment has been minimized.

Show comment
Hide comment
@Ghalleb

Ghalleb Nov 5, 2012

The hierarchy:

@MappedSuperclass
public abstract class CommonOrganizationalUnit<T extends EntityLocalized, E extends TenantPreference, P extends CommonOrganizationalUnit<?, ?, ?>> extends
    LocalizableEntity<T> implements Serializable, IComposite, Comparable<CommonOrganizationalUnit<T, E, P>> {

@MappedSuperclass
public abstract class ProductionSurface<T extends EntityLocalized, E extends TenantPreference, P extends CommonOrganizationalUnit<?, ?, ?>> extends
    CommonOrganizationalUnit<T, E, P> implements Serializable {


@Entity
public class Building extends ProductionSurface<BuildingLocalized, BuildingPreference, Site> {

The extends classes:

@MappedSuperclass
public abstract class EntityLocalized extends CommonEntity {

@Entity
@Table(name = "preference")
@DiscriminatorColumn(name = "discriminator", discriminatorType = DiscriminatorType.STRING)
public abstract class TenantPreference extends Preference {

@MappedSuperclass
public abstract class LocalizableEntity<T extends EntityLocalized> extends CommonEntity {

A lot of recursion....

Ghalleb commented Nov 5, 2012

The hierarchy:

@MappedSuperclass
public abstract class CommonOrganizationalUnit<T extends EntityLocalized, E extends TenantPreference, P extends CommonOrganizationalUnit<?, ?, ?>> extends
    LocalizableEntity<T> implements Serializable, IComposite, Comparable<CommonOrganizationalUnit<T, E, P>> {

@MappedSuperclass
public abstract class ProductionSurface<T extends EntityLocalized, E extends TenantPreference, P extends CommonOrganizationalUnit<?, ?, ?>> extends
    CommonOrganizationalUnit<T, E, P> implements Serializable {


@Entity
public class Building extends ProductionSurface<BuildingLocalized, BuildingPreference, Site> {

The extends classes:

@MappedSuperclass
public abstract class EntityLocalized extends CommonEntity {

@Entity
@Table(name = "preference")
@DiscriminatorColumn(name = "discriminator", discriminatorType = DiscriminatorType.STRING)
public abstract class TenantPreference extends Preference {

@MappedSuperclass
public abstract class LocalizableEntity<T extends EntityLocalized> extends CommonEntity {

A lot of recursion....

@Ghalleb

This comment has been minimized.

Show comment
Hide comment
@Ghalleb

Ghalleb Nov 6, 2012

Hi Timo,

Do you have a Maven Snapshot Repository where I could retrieve the jar?

Ghalleb commented Nov 6, 2012

Hi Timo,

Do you have a Maven Snapshot Repository where I could retrieve the jar?

@timowest

This comment has been minimized.

Show comment
Hide comment
@timowest

timowest Nov 19, 2012

Member

Released in 2.9.0

Member

timowest commented Nov 19, 2012

Released in 2.9.0

@timowest timowest closed this Nov 19, 2012

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment