1

Hi I Have created a custom entity and how can i save the custom entity to database is there any methods to save the custom entity please help me to solve the issue

Thanks In Advance

Santoshraju V
  • 330
  • 1
  • 13

1 Answers1

0

Broadleaf has tutorials on how to create your own entity here. I assume that you are now trying to persist this entity. In this case, you should create a Spring component that has @Transactional on it:

@Service
public class MyCustomEntityService {

    @PersistenceContext(unitName = "blPU")
    private EntityManager em;

    @Transactional
    public CustomEntity save(CustomEntity ce) {
        return em.merge(ce);
    }
}

You can also add Spring Data to your project, create a custom repository extending from Spring Data's CrudRepository and use methods there.

phillipuniverse
  • 2,025
  • 1
  • 14
  • 15