public void associate(int roomNumber, String type) { //got error
        TypeEntity tempType = new TypeEntity();
        Query q = em.createQuery("SELECT t from TypeEntity t");
        for (Object o : q.getResultList()) {
            TypeEntity p = (TypeEntity) o;
            if (p.getName().equals(type)) {
                System.out.println("found type" + p.getName());
                tempType = p;
            }
        }

        RoomEntity re = new RoomEntity();
        re.create(roomNumber);
        re.setType(tempType);
        tempType.getRooms().add(re);

        em.merge(re);
        em.merge(tempType);

    }