Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4033830
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T11:53:45+00:00 2026-05-20T11:53:45+00:00

I have following entity class User: public class User implements Serializable { @Column(length =

  • 0

I have following entity class User:

public class User implements Serializable {

    @Column(length = 10, name = "user_type")
    @Access(AccessType.PROPERTY)
    private String userTypeS;

    @Transient
    private UserType userType;
    ...
    public void setUserType(UserType userType) {
        this.userType = userType;
        this.userTypeS = this.userType.getType();
    }

    protected void setUserTypeS(String userTypeS) {
        this.userTypeS = userTypeS;
        userType = UserType.toUserType(userTypeS);
    }

UserType is an enum.
This issue was that I could not simply use the @Enumerated annotation to map UserType since the presentation of the enums in the code is different from that in the, e.g.:

public enum UserType {
CUSTOMER_NON_PRO("custnop") ...

When workign with the entity I wanted to be able to set the enum as userType and not the String representation of it. For this I created a public setter that sets the enum (userType) and translates it to the String representation of it (which is mapped with hibernate). Similarly there is a protected setUserTypeS which must be called by hibernate and will map the String userType to the enum UserType.

For this of course hibernate must use the setters to populate the entity. In our project it is preferred to set the annotations on the properties themselves i.o. the getters/setters. Hence hibernate will set the property values directly using introspection (and will thereby bypass the setters). For userTypeS I indicated that the access type is PROPERTY (i.o. FIELD) and because of that hibernate will call setUSerTypeS.

All of this works smoothly. The ‘problem’ is that in our logs we see following warning appear:

org.hibernate.cfg.AnnotationBinder – Placing @Access(AccessType.PROPERTY) on a field does not have any effect.

This warning does not appear to be correct. If I would remove @Access(AccessType.PROPERTY) from the field userTypeS then hibernate would not call the setter and hence the enum userType would not be set. So, placing @Access(AccessType.PROPERTY) does have affect.

Is this warning message invalid or outdated or am I misunderstanding something anyway?

thanks,
Stijn

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T11:53:46+00:00Added an answer on May 20, 2026 at 11:53 am

    @Access(AccessType.PROPERTY) is meant to be placed on a getter, like:

    @Access(AccessType.PROPERTY)
    @Column(length = 10, name = "user_type")
    public String getUserType() {
        return this.userType.getType();
    }
    
    public void setUserType(UserType userType) {
        this.userType = userType;
    }
    
    protected void setUserType(String userType) {
        userType = UserType.toUserType(userTypeS);
    }
    

    private String userTypeS; is not needed at all.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following java class: package domain; //imports @Entity public class User {
I have written the following code: @Entity @Table(name=person) @Inheritance(strategy=InheritanceType.JOINED) public class Person { private
I have the following entity public class DocumentHistory { public string Name { get;
I have the following entity structure: public class Party { public Int32 PartyId {
We have the following two entities with many-to-many association: @Entity public class Role {
my application has the following entity: public class User { public virtual int UserID
Let's say I have the following entity: public class Store { public List<Product> Products
I have the following Entity Framework POCO classes: public class Customer { public int
I have the following entity class (in Groovy): import javax.persistence.Entity import javax.persistence.Id import javax.persistence.GeneratedValue
I have an abstract class that looks as follows. public abstract class Entity<PK extends

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.