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 6106121
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T14:02:45+00:00 2026-05-23T14:02:45+00:00

I got exception: duplicate key value violates unique constraint client_pkey Key (xmppid)=(xyz813@deweet/prototype1006) already exists.

  • 0

I got exception: duplicate key value violates unique constraint “client_pkey”
Key (xmppid)=(xyz813@deweet/prototype1006) already exists.

My configuration is Tomcat 6.0, hibernate 3.3.1, c3pO 0.9.2 or dbcp.

I don’t know how to avoid this I thought that making it UniqueConstraint and calling it in transaction should sole everything.

Could you tip me what am I doing wrong?

@Override
@Transactional(readOnly = false)
public Client createClient(String userid) {
    Client c = new Client(userid);
    currentSession().save(c);
    return c;
}

The client class is defined as below

@Entity
@Table(name = "CLIENT", uniqueConstraints = { @UniqueConstraint(columnNames = { "xmppId" }) })
public class Client {


    @Id
    private String xmppId;


    @Override
    public boolean equals(Object o) {
        Client c = (Client) o;
        if (c.xmppId.equals(this.xmppId))
            return true;
        return false;
    }

    @Override
    public int hashCode() {
        return this.xmppId.hashCode();
    }

    ...
}

It doesnt point directly to this method, but to $Proxy23.createClient but i think it is
the only place I create and save client.

at $Proxy23.createClient(Unknown
Source) at
pl.samsung.cs.deweet.server.RequestHandler.onAddVirtualDevice(RequestHandler.java:182)
at
pl.samsung.cs.deweet.server.RequestHandler.handleRequests(RequestHandler.java:117)
at
pl.samsung.cs.deweet.network.impl.XmppNetContext$8$1.run(XmppNetContext.java:518)
at java.lang.Thread.run(Unknown
Source)

  • 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-23T14:02:45+00:00Added an answer on May 23, 2026 at 2:02 pm

    You don’t use auto generated id. That means that you will have to assign it (userId, presumably). When you call save it will attempt to insert it every time and you get an exception.

    Depending on what you’re trying to accomplish, you may use saveOrUpdate in place of save.

    See this reference http://www.javabeat.net/tips/161-difference-between-hibernates-saveupdate-a.html

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

Sidebar

Related Questions

I got the following class : class ConstraintFailureSet(dict, Exception) : Container for constraint failures.
I've got some LINQ to SQL that sometimes throws a Cannot insert duplicate key
Possible Duplicate: Causes of 'java.lang.NoSuchMethodError: main Exception in thread “main”' i got this error
I've got an Account model object and a UNIQUE constraint on the account's Name.
I've got exception about convert NULL to Int32. I've got a table from database
I got a strange exception when trying to find out if a property in
I got this error Unhandled exception at 0x0049b946 in Program.exe: 0xC0000005: Access violation reading
I got an out of memory exception in a photo editor thingy i was
I got the following Design time exception for my control in WPF System.NotImplementedException The
i got a webservicedefinition like this: [OperationContract] [FaultContract(typeof(Exception))] [WebInvoke(ResponseFormat = WebMessageFormat.Xml, BodyStyle = WebMessageBodyStyle.Wrapped,

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.