You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Can we expect the support to javax.persistence.ElementCollection any soon ? For me, I have a use-case to use my existing JPA entities also in android. OrmLite looks very promising to do so, however it is just about this specific annotation right now.
I evaluated also the com.j256.ormlite.dao.ForeignCollection but the difference there is it would create a single table and add a foreign key to it.
Minimal structure of my entities looks like :
``
In case anyone else is trying to achieve the same, I have implemented this as an extension to com.j256.ormlite.field.types.SerializableType.
Assumption : The elements marked as @ElementCollection are java.io.Serializable (there is however no such hard check)
`import com.j256.ormlite.field.SqlType;
import com.j256.ormlite.field.types.SerializableType;
import java.lang.reflect.Field;
import javax.persistence.ElementCollection;
/**
* Persistor which can be used for persisting {@link ElementCollection} fields, assuming such fields are {@link java.io.Serializable}.
*/
public class SerializedElementCollectionPersister extends SerializableType {
private static SerializedElementCollectionPersister singleTon = null;
private SerializedElementCollectionPersister() {
super(SqlType.SERIALIZABLE, new Class[]{});
}
public static SerializedElementCollectionPersister getInstance() {
if (singleTon == null) {
singleTon = new SerializedElementCollectionPersister();
}
return singleTon;
}
@Override
public boolean isValidForField(Field field) {
return field.getAnnotation(ElementCollection.class) != null;
}
}`
This is then registered as a "custom persister" => DataPersisterManager.registerDataPersisters(SerializedElementCollectionPersister.getInstance())
Can we expect the support to
javax.persistence.ElementCollection
any soon ? For me, I have a use-case to use my existing JPA entities also in android. OrmLite looks very promising to do so, however it is just about this specific annotation right now.I evaluated also the
com.j256.ormlite.dao.ForeignCollection
but the difference there is it would create a single table and add a foreign key to it.Minimal structure of my entities looks like :
``
``
``
``
``
``
Hibernate creates following tables:
actual_entity => some_element, some_number
actual_entity_embeddable_entity_list => key, value, actual_entity_id
second_actual_entity => some_element, some_number
second_actual_entity_embeddable_entity_list => key, value, second_actual_entity_id
The text was updated successfully, but these errors were encountered: