Question

I get exception "There is no default persistence unit in this deployment." can I somehow mark unit as default?(I have only one persistence unit, so Id rather not call it by name)

Was it helpful?

Solution

No, you have to call PU's by name.

OTHER TIPS

You are probably doing it through code rather than letting the container manage it. In which case you have to specify by name.

My unit test code has this code block to do this.

@Before
public void createEntityManagerFactory() throws IOException {
    final Properties p = new Properties();
    p.load(getClass().getResourceAsStream("/inmemory.properties"));
    emf = Persistence.createEntityManagerFactory("default", p);
}

However, my application code looks like this.

/**
 * Injected persistence context.
 */
@PersistenceContext
private EntityManager em;
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top