Skip to content

Commit

Permalink
#27 : fixed NPE in Embedded handling
Browse files Browse the repository at this point in the history
  • Loading branch information
timowest committed Oct 12, 2011
1 parent 3fa7d7d commit 90a797d
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 1 deletion.
Expand Up @@ -638,7 +638,9 @@ private void processEmbedded() {
typeName = typeName.substring(0, typeName.indexOf('<'));
}
TypeElement typeElement = env.getElementUtils().getTypeElement(typeName);
if (typeElement.getAnnotation(configuration.getEntityAnnotation()) != null){
if (typeElement == null) {
continue;
} else if (typeElement.getAnnotation(configuration.getEntityAnnotation()) != null){
// skip Entity types here
continue;
}
Expand Down
@@ -0,0 +1,51 @@
package com.mysema.query.domain;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;

import javax.persistence.Column;
import javax.persistence.Embeddable;
import javax.persistence.Embedded;
import javax.persistence.Entity;
import javax.persistence.MappedSuperclass;

import org.junit.Test;

public class EmbeddedTest {

@Entity
public class EntityClass extends AbstractEntity<SubEntityCode> {

}

@MappedSuperclass
public abstract class AbstractEntity<C extends EntityCode> {

@Embedded
@Column(name = "code", nullable = false, unique = true)
C code;
}

@MappedSuperclass
public class EntityCode {

@Column(name = "code", unique = true)
String code;

}

@Embeddable
public class SubEntityCode extends EntityCode {

String property;

}

@Test
public void EntityClass() {
assertNotNull(QEmbeddedTest_EntityClass.entityClass.code.property);
assertEquals(SubEntityCode.class, QEmbeddedTest_EntityClass.entityClass.code.getType());
}


}

0 comments on commit 90a797d

Please sign in to comment.