Hello, I am currently working for a university project about digital
humanities, basically its an app where you can read books and make and share
annotations to it. Im facing a problem that got me stuck for 4 days long
now, and I do not know what to do.
Here is the tech spec: Annotatio: has many AnnotationType. Lets say that I
have to AnnotationTypes i.e ''sadness" and "tradegy". Then the app
administrator realises that both AnnotationType are the same so he wants to
merge sadness and tradegy to be AnnotationType tradegy only.
So in order to make this my approach is to first grab all the annotations
whose annotationType.getName() == comedy and then set the new
AnnotationType in the whole list. here's the code.
@Entity
@Table(name = "annotation")
public class Annotation implements Serializable, IsSerializable {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Key id;
private String bookId;
@Basic
@ManyToOne(cascade = CascadeType.PERSIST, fetch = FetchType.LAZY)
private AnnotationType annotationType;
}
@Entity
@Table(name = "annotation_type")
public class AnnotationType implements Serializable, IsSerializable {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Key id;
private String name;
@Basic
@OneToMany(cascade = CascadeType.ALL,mappedBy = "annotationType")
private ArrayList<Annotation> annotations;
}
And heres the method fusionAnnotationType
public int fusionAnnotationTypes(AnnotationType annotationType1,
AnnotationType annotationType2) throws GeneralException,
AnnotationTypeNotFoundException, NullParameterException {
int total = 0;
List<Annotation> annotations2 = new ArrayList<Annotation>();
List<AnnotationType> annotationTypes2;
entityManager = EMF.get().createEntityManager();
if (annotationType1 == null || annotationType2 == null) {
throw new NullParameterException("Parameter cant be null in
method deleteDnServices");
}
try {
String sql2 = "SELECT a FROM Annotation a WHERE
a.annotationType" + annotationType2;
annotations2 = entityManager.createQuery(sql2).getResultList();
AnnotationType auxAnnotationType = new AnnotationType();
for (int i = 0; i < annotations2.size(); i++) {
annotations2.get(i).setAnnotationType(annotationType1);
saveAnnotation(annotations2.get(i));
}
} catch (Exception e) {
entityTransaction.rollback();
throw new GeneralException("Exception in method
fusionAnnotationTypes: " + e.getMessage());
} finally {
if (entityManager.isOpen()) {
entityManager.close();
}
}
return total;
}
when executing it jumps this message error: Portion of expression could not
be parsed: @164a05d
I have also tried to fetch "SELECT a FROM Annotation a WHERE
a.annotationType.name" + annotationType2.getName(); and annother exception
occured: Can only reference properties of a sub-object if the sub-object is
embedded."
Can you please help me out on this, I really do not know what to do. another
thing that I also tried was fetching the AnnotationType and then getting its
annotationList and do the same project, but it complains again throwing
another exception about entity groups.
I really need some help.
cheers.
Kido.
--
You received this message because you are subscribed to the Google Groups
"Google App Engine for Java" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/google-appengine-java?hl=en.