public void create(TObject TObject) {
        if (TObject.getObjectFieldsList() == null) {
            TObject.setObjectFieldsList(new ArrayList<ObjectFields>());
        }
        EntityManager em = null;
        try {
            em = getEntityManager();
            em.getTransaction().begin();
            List<ObjectFields> attachedObjectFieldsList = new ArrayList<ObjectFields>();
            for (ObjectFields objectFieldsListObjectFieldsToAttach : TObject.getObjectFieldsList()) {
                objectFieldsListObjectFieldsToAttach = em.getReference(objectFieldsListObjectFieldsToAttach.getClass(), objectFieldsListObjectFieldsToAttach.getId());
                attachedObjectFieldsList.add(objectFieldsListObjectFieldsToAttach);
            }
            TObject.setObjectFieldsList(attachedObjectFieldsList);
            em.persist(TObject);
            for (ObjectFields objectFieldsListObjectFields : TObject.getObjectFieldsList()) {
                TObject oldObjectIdOfObjectFieldsListObjectFields = objectFieldsListObjectFields.getTObject();
                objectFieldsListObjectFields.setObjectId(TObject);
                objectFieldsListObjectFields = em.merge(objectFieldsListObjectFields);
                if (oldObjectIdOfObjectFieldsListObjectFields != null) {
                    oldObjectIdOfObjectFieldsListObjectFields.getObjectFieldsList().remove(objectFieldsListObjectFields);
                    oldObjectIdOfObjectFieldsListObjectFields = em.merge(oldObjectIdOfObjectFieldsListObjectFields);
                }
            }
            em.getTransaction().commit();
        } finally {
            if (em != null) {
                em.close();
            }
        }
    }