Format of generated values

Report a typo

Which of the given identifiers can be generated by the RandomGenerator class, which is defined in the com.example package?

@Entity
@Table(name = "users")
public class User {
    @Id
    @GeneratedValue(generator = "uuid")
    @GenericGenerator(name = "uuid", strategy = "com.example.RandomGenerator")
    private String id;
 
    private String name;
    private int age;
 
    // constructors, getters, setters, etc.
}
package com.example;

public class RandomGenerator implements IdentifierGenerator {

    @Override
    public Serializable generate(SharedSessionContractImplementor session, Object object) throws HibernateException {
        return createValue();
    }

    public String createValue() {
        Random rn = new Random();
        StringBuilder sb = new StringBuilder();
        sb.append("hyperskill-");
        sb.append(rn.nextInt(10000));
        return sb.toString();
    }

}
Select one or more options from the list

Create a free account to access the full topic