is it possible to define two keys in hibernate, so i can hit the first-level-cache with both keys?
@Entity
class User {
@Id
int id;
@Id
String username;
}
so session.get(User.class, ‘harry’) is the same as session.get(User.class, 1)
is it possible?
You might be interested in this feature of 4.1
You can in fact hit the first level cache using the @Id or the @NaturalId. Just make sure you are using 4.1.x.