-
Notifications
You must be signed in to change notification settings - Fork 100
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
commit transaction #10
Comments
Are you sure that the JPA transaction is correctly declared ? |
The declaration of JPA is:
I'm using hibernate5. The problem is that until the end of the Rest API the deleteAll is not executed, only at the end of the function there are a commit and a Sqlite log. |
So I still don't known/have the SQLite driver used, the SQLite traces (not the hibernate traces because drivers execute their owns queries), and no sample.
? |
The driver is:
The sample is:
I have added trying to force the commit |
with:
and also deleting only What else could I tweak them? |
I can't reproduce the error: @Service("clientService")
public class ClientServiceImpl implements ClientService {
@PersistenceContext
private EntityManager entityManager;
// ...
@Transactional
public void replaceAll(Client client) {
entityManager.createQuery("DELETE FROM Client").executeUpdate();
entityManager.persist(client);
entityManager.flush();
}
} @Transactional
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = "classpath:/META-INF/spring/applicationContext*.xml")
public class ClientServiceTest {
@Autowired
private ClientService clientService;
@Test
public void testReplaceAll() {
final Client c = new Client("client1", "code1");
clientService.replaceAll(c);
}
}
No database locked. |
Hi there!
the exception jump up when Hibernate tries to take the next Id on @GeneratedValue id property
following my jpa/hibernate configurations:
as suggested by @gwenn i tried to add
that doesn't resolve my problem but i have had a different error
may be an error with @GeneratedValue annotation in Entity class?? Strange thing: I have a Unit test (inmemory db) that runs the same code and it works without problems. |
Why do you use |
See 43fdae9 (but useful only with GenerationType.IDENTITY). |
in a Rest API I called:
But that gives me: database is locked
That's because the transactions aren't committed to the database, until the end of the Rest API the deleteAll isn't executed on the database and the resource isn't released.
The text was updated successfully, but these errors were encountered: