Main   Products   Offshore Outsourcing   Customers   Partners   ContactUs  
JDBC Databases
  HXTT Access v7.1
  HXTT Cobol v5.0
  HXTT DBF v7.1
 
  Buy Now
  Support
  Download
  Document
  FAQ
  HXTT Excel v6.1
  HXTT Json v1.0
  HXTT Paradox v7.1
  HXTT PDF v2.0
  HXTT Text(CSV) v7.1
  HXTT Word v1.1
  HXTT XML v4.0
Offshore Outsourcing
Free Resources
  Firewall Tunneling
  Search Indexing Robot
  Conditional Compilation
  Password Recovery for MS Access
  Password Recovery for Corel Paradox
  Checksum Tool for MD5
  Character Set Converter
  Pyramid - Poker of ZYH
   
   
   
Heng Xing Tian Tai Lab of Xi'an City (abbr, HXTT)

HXTT DBF
Duplicate on Primary Key
Kit
2013-04-23 14:06:55
Using the code below, I was able to create multiple duplicates of the same Station Name, even though the StationName is the primary key.

Code to add data:
Station wmStation = new Station();
wmStation.setStationName(station.getAgentName());
wmStation.setStationDesc(station.getFirstName() + " " + station.getLastName());
wmEmgr.getTransaction().begin();
wmEmgr.persist(wmStation);
wmEmgr.getTransaction().commit();



Entity Class:

package wm.wmdata;

import java.io.Serializable;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;

/**
*
* @author jeick
*/
@Entity
@Table(name = "zSTATION")
@NamedQueries({
@NamedQuery(name = "Station.findByPartSerialNumber", query = "SELECT c FROM Station c WHERE c.stationName = :stationName")})
public class Station implements Serializable {

private static final long serialVersionUID = 1L;
@Id
@Basic(optional = false)
@Column(name = "STATNAME", nullable = false, length = 50)
private String stationName;
@Basic(optional = false)
@Column(name = "STATDESC", nullable = false, length = 254)
private String stationDesc;

public Station() {
}

public String getStationName() {
return stationName;
}

public void setStationName(String stationName) {
this.stationName = stationName;
}

public String getStationDesc() {
return stationDesc;
}

public void setStationDesc(String stationDesc) {
this.stationDesc = stationDesc;
}
}
Re:Duplicate on Primary Key
HXTT Support
2013-04-23 17:27:10
Try
select * from Station group by stationName having count(stationName )>1;
To see whether there's duplicate row.
If it exists, please check whether there's primary key index on stationName.
Re:Re:Duplicate on Primary Key
Kit
2013-04-23 17:45:37
By having the @Id label on the stationName in the Entity class, shouldn't that identify that column as the primary key?
Re:Re:Re:Duplicate on Primary Key
HXTT Support
2013-04-23 17:57:56
>By having the @Id label on the stationName in the Entity class
If you wish to add a primary key for existent table, you need to run once:
CREATE INDEX stationName ON Station (stationName PRIMARY KEY);
Re:Re:Re:Re:Duplicate on Primary Key
Kit
2013-05-24 07:51:12
Does this apply to Visual FoxPro 9.0, because my VFP admin says that it doesn't need this command. Could you please clarify this for me?
Re:Re:Re:Re:Re:Duplicate on Primary Key
HXTT Support
2013-05-24 17:17:14
That sql is only used by HXTT DBF.
You can create a primary key index in VFP 9.0 through VFP command also. Then HXTT DBF can see it.

Search Key   Search by Last 50 Questions




Google
 

Email: webmaster@hxtt.com
Copyright © 2003-2019 Heng Xing Tian Tai Lab of Xi'an City. | All Rights Reserved. | Privacy | Legal | Refund | Sitemap