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

  • Home
  • SEARCH
  • 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 6878141
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T04:41:13+00:00 2026-05-27T04:41:13+00:00

I have the following Exception when i’m try to insert values in the database.

  • 0

I have the following Exception when i’m try to insert values in the database.
This is my persistence class:

<pre> 
@SuppressWarnings("serial")
@Entity
@Table(name = "consumer", catalog = "oauth")
@NamedQueries({
    @NamedQuery(name = Consumer.QUERY_BY_CONSUMER_KEY, query = "SELECT i FROM " + Consumer.TABLENAME + " i WHERE i.consumerKey = :" + Consumer.Q_PARAM_CONSUMER_KEY)})
public class Consumer implements java.io.Serializable {

    public static final String TABLENAME = "Consumer";
    public static final String QUERY_BY_CONSUMER_KEY = "ConsumerFindByConsumerKey";
    public static final String Q_PARAM_CONSUMER_KEY = "consumer_key";
    @Id
    @GeneratedValue(strategy = IDENTITY)
    @Column(name = "id", unique = true, nullable = false)
    private Integer id;
    @ManyToOne
    @JoinColumn(name = "user_id", nullable = false)
    private Idpuser idpuser;
    @Column(name = "description", nullable = false, length = 500)
    private String description;
    @Column(name = "consumer_key", nullable = false, length = 100)
    private String consumerKey;
    @Column(name = "consumer_secret", nullable = false, length = 100)
    private String consumerSecret;
    @Column(name = "callbackurl", nullable = false, length = 400)
    private String callbackURL;
    @Column(name = "request_token", length = 500)
    private String requestToken;
    @Column(name = "token_secret", length = 500)
    private String tokenSecret;
    @Column(name = "access_token", length = 500)
    private String accessToken;
    @Temporal(TemporalType.TIMESTAMP)
    @Column(name = "acces_token_valid_from", length = 19)
    private Date accesTokenValidFrom;
    @Temporal(TemporalType.TIMESTAMP)
    @Column(name = "access_token_valid_to", length = 19)
    private Date accessTokenValidTo;
    @Column(name = "access_token_num_usage_count")
    private Integer accessTokenNumUsageCount;
    @Column(name = "access_token_max_usage_count")
    private Integer accessTokenMaxUsageCount;
    @Column(name = "authorized", nullable = false)
    private Boolean authorized;
    @ManyToMany(fetch= FetchType.EAGER)
    @JoinTable(name = "consumer_role_relation",
    joinColumns = { 
      @JoinColumn(name = "consumer_id")
    }, 
    inverseJoinColumns = {
      @JoinColumn(name = "role_id")
    }
    )
    private Set<Role> roles = new HashSet<Role>(0);

    @Column(name = "facebookId", unique = true)
    private BigInteger facebookId;


    protected Consumer() {
    }

    public Consumer(Idpuser idpuser, String describtion, String consumerKey, String consumerSecret, String callbackURL,
            String requestToken, String tokenSecret, String accessToken, boolean authorized) {
        this.idpuser = idpuser;
        this.description = describtion;
        this.consumerKey = consumerKey;
        this.consumerSecret = consumerSecret;
        this.callbackURL = callbackURL;
        this.requestToken = requestToken;
        this.tokenSecret = tokenSecret;
        this.accessToken = accessToken;
        this.authorized = authorized;
    }

    public Consumer(Idpuser idpuser, String describtion, String consumerKey, String consumerSecret, String callbackURL,
            String requestToken, String tokenSecret, String accessToken, boolean authorized,
            Date accesTokenValidFrom, Date accessTokenValidTo, int accessTokenMaxUsageCount) {
        this.idpuser = idpuser;
        this.description = describtion;
        this.consumerKey = consumerKey;
        this.consumerSecret = consumerSecret;
        this.callbackURL = callbackURL;
        this.requestToken = requestToken;
        this.tokenSecret = tokenSecret;
        this.accessToken = accessToken;
        this.authorized = authorized;
        this.accesTokenValidFrom = accesTokenValidFrom;
        this.accessTokenValidTo = accessTokenValidTo;
        this.accessTokenMaxUsageCount = accessTokenMaxUsageCount;
    }

    public Consumer(Idpuser idpuser, String describtion, String consumerKey, String consumerSecret, String callbackURL,
            String requestToken, String tokenSecret, String accessToken, boolean authorized,
            Date accesTokenValidFrom, Date accessTokenValidTo, int accessTokenMaxUsageCount, Set<Role> roles) {
        this.idpuser = idpuser;
        this.description = describtion;
        this.consumerKey = consumerKey;
        this.consumerSecret = consumerSecret;
        this.callbackURL = callbackURL;
        this.requestToken = requestToken;
        this.tokenSecret = tokenSecret;
        this.accessToken = accessToken;
        this.authorized = authorized;
        this.accesTokenValidFrom = accesTokenValidFrom;
        this.accessTokenValidTo = accessTokenValidTo;
        this.accessTokenMaxUsageCount = accessTokenMaxUsageCount;
        this.roles = roles;
    }

    public Consumer(Idpuser idpuser, String describtion, String consumerKey, String consumerSecret, String callbackURL,
            String requestToken, String tokenSecret, String accessToken, boolean authorized,
            Date accesTokenValidFrom, Date accessTokenValidTo) {
        this.idpuser = idpuser;
        this.description = describtion;
        this.consumerKey = consumerKey;
        this.consumerSecret = consumerSecret;
        this.callbackURL = callbackURL;
        this.requestToken = requestToken;
        this.tokenSecret = tokenSecret;
        this.accessToken = accessToken;
        this.authorized = authorized;
        this.accesTokenValidFrom = accesTokenValidFrom;
    }


    public Consumer(Idpuser idpuser, String describtion, String consumerKey, String consumerSecret, String callbackURL,
            String requestToken, String tokenSecret, String accessToken, boolean authorized,
            Date accesTokenValidFrom, Date accessTokenValidTo, Set<Role> roles) {
        this.idpuser = idpuser;
        this.description = describtion;
        this.consumerKey = consumerKey;
        this.consumerSecret = consumerSecret;
        this.callbackURL = callbackURL;
        this.requestToken = requestToken;
        this.tokenSecret = tokenSecret;
        this.accessToken = accessToken;
        this.authorized = authorized;
        this.accesTokenValidFrom = accesTokenValidFrom;
        this.roles = roles;
    }


    public Integer getId() {
        return this.id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public Idpuser getIdpuser() {
        return this.idpuser;
    }

    public void setIdpuser(Idpuser idpuser) {
        this.idpuser = idpuser;
    }

    public String getDescription() {
        return this.description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public String getConsumerKey() {
        return this.consumerKey;
    }

    public void setConsumerKey(String consumerKey) {
        this.consumerKey = consumerKey;
    }

    public String getConsumerSecret() {
        return this.consumerSecret;
    }

    public void setConsumerSecret(String consumerSecret) {
        this.consumerSecret = consumerSecret;
    }

    public String getCallbackURL() {
        return callbackURL;
    }

    public void setCallbackURL(String callbackURL) {
        this.callbackURL = callbackURL;
    }

    public Date getAccesTokenValidFrom() {
        return accesTokenValidFrom;
    }

    public void setAccesTokenValidFrom(Date accesTokenValidFrom) {
        this.accesTokenValidFrom = accesTokenValidFrom;
    }

    public String getAccessToken() {
        return accessToken;
    }

    public void setAccessToken(String accessToken) {
        this.accessToken = accessToken;
    }

    public Integer getAccessTokenMaxUsageCount() {
        return accessTokenMaxUsageCount;
    }

    public void setAccessTokenMaxUsageCount(Integer accessTokenMaxUsageCount) {
        this.accessTokenMaxUsageCount = accessTokenMaxUsageCount;
    }

    public Integer getAccessTokenNumUsageCount() {
        return accessTokenNumUsageCount;
    }

    public void setAccessTokenNumUsageCount(Integer accessTokenNumUsageCount) {
        this.accessTokenNumUsageCount = accessTokenNumUsageCount;
    }

    public Date getAccessTokenValidTo() {
        return accessTokenValidTo;
    }

    public void setAccessTokenValidTo(Date accessTokenValidTo) {
        this.accessTokenValidTo = accessTokenValidTo;
    }

    public Boolean getAuthorized() {
        return authorized;
    }

    public void setAuthorized(Boolean authorized) {
        this.authorized = authorized;
    }

    public String getRequestToken() {
        return requestToken;
    }

    public void setRequestToken(String requestToken) {
        this.requestToken = requestToken;
    }

    public String getTokenSecret() {
        return tokenSecret;
    }

    public void setTokenSecret(String tokenSecret) {
        this.tokenSecret = tokenSecret;
    }  

    public Set<Role> getRoles(){
        return this.roles;
    }

    public void setRoles(Set<Role> roles){
        this.roles = roles;
    }

    public void addRole(Role r){
        this.roles.add(r);
    }

    public void removeRole(Role r){
        this.roles.remove(r);
    }

    @Override
    public String toString(){
        return this.description;
    }



    /* (non-Javadoc)
     * @see java.lang.Object#hashCode()
     */
    @Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result
                + ((consumerSecret == null) ? 0 : consumerSecret.hashCode());
        return result;
    }

    /* (non-Javadoc)
     * @see java.lang.Object#equals(java.lang.Object)
     */
    @Override
    public boolean equals(Object obj) {
        if (this == obj)
            return true;
        if (obj == null)
            return false;
        if (getClass() != obj.getClass())
            return false;
        Consumer other = (Consumer) obj;
        if (consumerSecret == null) {
            if (other.consumerSecret != null)
                return false;
        } else if (!consumerSecret.equals(other.consumerSecret))
            return false;
        return true;
    }



    /* ###### Listener handling ###########################  */
    @Transient
    private CopyOnWriteArrayList<Object> listeners = new CopyOnWriteArrayList<Object>();

    public CopyOnWriteArrayList<Object> getListeners() {
        return listeners;
    }

    public void setListeners(CopyOnWriteArrayList<Object> listeners) {
        this.listeners = listeners;
    }

    public BigInteger getFacebookId() {
        return facebookId;
    }

    public void setFacebookId(BigInteger facebookId) {
        this.facebookId = facebookId;
    }    
}

</pre>

Exception:

<pre>
Dez 03, 2011 12:58:21 PM org.hibernate.util.JDBCExceptionReporter logExceptions
Warnung: SQL Error: 1364, SQLState: HY000
Dez 03, 2011 12:58:21 PM org.hibernate.util.JDBCExceptionReporter logExceptions
Schwerwiegend: Field 'describtion' doesn't have a default value
Exception in thread "main" javax.persistence.PersistenceException: org.hibernate.exception.GenericJDBCException: could not insert: [org.idp.persistence.mappings.Consumer]
    at org.hibernate.ejb.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1214)
    at org.hibernate.ejb.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1147)
    at org.hibernate.ejb.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1153)
    at org.hibernate.ejb.AbstractEntityManagerImpl.merge(AbstractEntityManagerImpl.java:695)
    at org.idp.persistence.DataManager.saveOrUpdateEntity(DataManager.java:224)
    at org.idp.persistence.DataManager.saveOrUpdate(DataManager.java:142)
    at org.idp.persistence.mappings.Idpuser.addOrUpdateConsumer(Idpuser.java:259)
    at org.idp.playground.ReadTest.main(ReadTest.java:40)
</pre>

When i’m try to read from database it’s work. It is also working when i’m try to insert data into another Table (e.g. Idpuser). I’m also tried following solution advices:

  • set default value for the description field in the database
  • –

  • 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-27T04:41:14+00:00Added an answer on May 27, 2026 at 4:41 am

    It seems that your table has a column “describtion” (with a b), without a default value, whereas the entity has a field mapped to the column “description” (with a p).

    Make sure your mapping matches with the table columns.

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

Sidebar

Related Questions

I have this timer function, it gives me following exception. Collection was modified; enumeration
Background: Suppose I have the following obviously-incorrect PHP: try{ $vtest = ''; print(array_pop($vtest)); }catch(Exception
I have following entity (non-relevant fields/methods are removed). public class HitsStatsTotalDO { @Id transient
I have the following method in my database class that returns a resultset for
I have the following entity public class DocumentHistory { public string Name { get;
Note, this is some ancient NHibernate installation! I have the following NHibernate class: [Serializable]
I have the following entity in Hibernate: @Entity public class Contact implements Serializable {
I have following exception in the foreach loop Unable to cast object of type
I have seen the following exception case several times public SomeClass(IEnumerable<T> someValues) { if
I have the following error Exception in thread main javax.naming.NameNotFoundException: CounterBean not bound trying

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.