C
C
Cyrus Smith2016-02-02 05:35:01
MySQL
Cyrus Smith, 2016-02-02 05:35:01

Why doesn't Mysql increment Long?

Hello everyone, I
ran into a problem - in the users table, MySQL simply refuses to increment one of the columns (not pr.key). The column itself contains the BIGINT type. The table is generated based on Java code and annotations to it.

@GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "id", unique = true, nullable = false)
    private Long id;

During the test (code below), it gives an error (the log is even lower). setId () I do not spend, because I want to shift it to the database.
@Test
    public void AddAllFields() throws Exception {
        User user = new User();
        user.setUsername("demo");
        user.setPassword("demo");
        user.setRole(EnumRoles.ROLE_USER);
        user.setEnabled(true);
        user.setPacks(null);
        user.setDetails(null);
        userService.add(user);
        assertEquals(user, userService.findByUsername("demo").get(0));
    }

org.hibernate.PropertyValueException: not-null property references a null or transient value : cards.server.entity.User.id

I tried to manually make this setting in the column - the result is zero. Can anyone help?
Thanks

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
aol-nnov, 2016-02-02
@aol-nnov

really why ???

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question