Hi,
I've got some DataTables with an ID column with AutoIncrement enabled both on the MySQL server side and the ADO.NET schema side (loaded from an XML schema file). I'd like not to have to care about these IDs when inserting rows because their sole use is to have a primary key for the table – there are no foreign key references. Howe...
I've had this come up a couple times in my career, and none of my local peers seems to be able to answer it. Say I have a table that has a "Description" field which is a candidate key, except that sometimes a user will stop halfway through the process. So for maybe 25% of the records this value is null, but for all that are not NULL, it ...
This is a toy example that illustrates a real problem in PostgreSQL. The below examples are using a PostgreSQL 8.4.3 server, but I suspect other versions have the same problem.
Given the following table:
=> create table tmp_foo (foo boolean not null unique, bar boolean not null unique);
=> insert into tmp_foo (foo, bar) values (true,...
I’m interested in learning which technique developers prefer to use to enforce uniqueness in SQL Server: UNIQUE CONSTRAINT or UNIQUE INDEX. Given that there is little difference in the physical implementation of each, how do you decide which is best?
Are there reasons other than performance to evaluate the best solution?
Are there da...
I have added an index on a table just to ensure that a set of fields together form a composite unique key (Is this approach correct? or is there a better option with Doctrine?)
After having done that, when I try to save an object and the unique constraint fails, a SQL exception is generated. What is the best way to handle this? and to d...
I have a field with an unique constraint:
@Column(unique=true)
private String uriTitle;
When I try to save two entities with the same value, I get an exception - but another exception than I exected:
java.lang.IllegalStateException: <|Exception Description: No transaction is currently active
at org.eclipse.persistence.interna...
I have rows in an Oracle database table which should be unique for a combination of two fields but the unique constrain is not set up on the table so I need to find all rows which violate the constraint myself using SQL. Unfortunately my meager SQL skills aren't up to the task.
My table has three columns which are relevant: entity_id, ...
I want to make sure that all rows in my table have a unique combination of two fields, and I want to specify this using annotations in my entity class. I have tried using a combination of @Table and @UniqueConstraint but apparently I'm doing it wrong, in that I can only seem to specify that the separate columns should be unique (I can a...
Hi All,
Below is the use case:
I have a unique index defined on 3 columns say A,B,C. Assume the values in them are A1,B1,C1.
My java code is adding a new record say A1,B1,C1 but before this record is added, i update the previous value from C1 to C2. While trying to add the new record (after the update), hibernate is throwing an unique c...
A top class called Parametric is used to create objects which can have parameters associated with them:
class Parametric(object):
def __init__(self, name):
self.name = name
self.pars = []
class Foo(Parametric):
def __init__(self, name, prop):
self.prop = prop
Parametric.__init__(self, name)
class Bar(Parametric):
def __init...
Hi all, i have an entity that contains two other entities with @ManyToOne relationship.
@Entity
public class A extends Serializable{
@Id
@GeneratedValue(strategy=GenerationType.IDENTITY)
private Long id;
@ManyToOne
@Cascade(CascadeType.SAVE_UPDATE)
private B b;
@ManyToOne
@Cascade(CascadeType.SAVE_UPDA...
I've been wondering lately. Lets say we're doing a webapp with JSF+Spring+JPA/Hibernate (or well any other technologies) and lets say we have a "User" entity. We want the User to have a unique login. If we want to do it then we can put a @UniqueConstraint on the "Login" column, but still our application has to check during user registrat...
Hi all
I use Entity Framework to access my SQL data. I have some constraints in the database schema and I wonder how to handle exceptions that are caused by these constraints.
As example, I get the following exception in a case where two users try to add an (almost) identical entity to the DB concurrently.
System.Data.UpdateException
...
What is the diffrence between a unique index and a unique key?
...
I have column in a table that allow null but i want to make constraint that make him null or unique ... How can i do that ?
Note : I validate it from the frontend but i want to have a physical in sql server that allow this even developer try to enter data
...
In my map I have:
Component(
x => x.ExposureKey,
m => {
m.Map(x => x.AsOfDate).Not.Nullable();
m.Map(x => x.ExposureId).Length(30).Not.Nullable();
}
).Unique();
The relevant output from the HBM is
<component name="ExposureKey" insert="true" update="true" optimistic-lock="true" class="Some.Namespace.CreditE...
The central problem: How do you merge attribute collections by a key during mass assignment from a nested form.
The details: I am using the following models:
class Location < ActiveRecord::Base
has_many :containers,
:dependent => :destroy,
:order => "container_type ASC"
validates_associated :containers
accepts_n...
In Oracle 10g, how can I drop a unique constraint on a column without knowing the name of the constraint (e.g. a system generated name, which won't necessarily be the same across database instances)? Dropping and recreating the table isn't an option. Is it possible?
...
In Oracle 10g, how do I add a unique case-insensitive constraint on two varchar fields? For example, given the following records already in the table:
"Stephen", "Swensen"
"John", "Smith"
The following inserts would be invalid:
"stephen", "Swensen"
"John", "smith"
"stephen", "swensen"
But the following inserts would be valid:
"St...
Hi,
I have a DAO where I need to catch an unique constraint exception. To do this, the only working solution is to flush my EntityManager after the persist. Only then I come into a catch block where I have to filter out the exception. And, my DAO method needs to be wrapped in a transaction (REQUIRES_NEW) otherwise I have the RollBackExc...