int intId = 1;
String nameId = "CompositeEntity";
EntityWithCompositeId entity = new EntityWithCompositeId();
entity.setId(intId);
entity.setName(nameId);
CompositeId id = new CompositeId(intId, nameId);
EntityManager em = emf.createEntityManager();
em.getTransaction().begin();
em.persist(entity);
em.getTransaction().commit();