constraints

Hibernate check deletion constraints

痴心易碎 提交于 2019-12-10 11:46:43
问题 I am using Spring - Hibernate to control models in my application. The models are linked to each other (one-to-many, many-to-many, almost kinds of relationships), and now I have a problem when deleting one entity which is being used by other entities. The problem is I want to show the detail message that informs exactly what other objects (type, name) are using the entity that I am going to delete. It's not the common message about Constraint violation that Hibernate throws me. For example:

UNIQUE - way to have unique rows in table?

我们两清 提交于 2019-12-10 10:55:57
问题 I have problem with unique rows in db table, now it is posible to do that: id | Name | LastName | City ------------------------------------- 1 | John | Moore | London 2 | John | Moore | London when i use UNIQUE attribute in all columns i have errors inserting second Moore even it is different Name :/ how use UNIQUE (or maybe INDEX?) to do something like that in my table in db: id | Name | LastName | City ------------------------------------- 1 | John | Moore | London 2 | Jake | Moore | London

Display an image in a scrollview with specific constraints (with auto layout)

痞子三分冷 提交于 2019-12-10 10:29:22
问题 I would like display a title and below a image in my view controller. My constraints are : the label can be at 50px of the top of the screen the label can have one or many rows the image can be at 50px of my label the image must have the width of the screen the scroll view must scroll depending on the size of all these elements I have a view controller with a scroll view : -view controller ---view ------scroll view ---------container view ------------label ------------image I want use

Custom cell in UITableView shifts right after swipe to edit

一笑奈何 提交于 2019-12-10 10:26:05
问题 I just want a simple UITableView with the ability to slide left to delete. Everything works okay except the right constraint on the textview in my prototype cell seems to get shifted after swiping to delete. Here's my code for the table: func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell { //Uses prototype cell from Interface Builder called "CommentTableCell" let tableCell = tableView.dequeueReusableCellWithIdentifier("CommentTableCell",

Oracle SQL Constraint where clause

情到浓时终转凉″ 提交于 2019-12-10 09:42:11
问题 I have the table Tester on oracle with the following columns: TesterID TesterName IsDefault Application_ID TesterID is the primary key. Now I want that there can only be one Default Tester, which means only one Tester can have the calues IsDefault =Y at an ApplicationID. I tried it with a constraint: alter table Tester add constraint Tester_ISDEFAULT UNIQUE(IsDefault,Application_ID); Is it possible to make the unique key on where isdefault= Y? Thanks for help! 回答1: Not with a UNIQUE

Set priority on constraints in swift

我们两清 提交于 2019-12-10 09:23:40
问题 I've been struggling to make priority on constraints work programmatically in swift. My goal is to have the meetingFormView no more than 300 wide. Using IB I would give the width constraint a lower priority and give a higher priority to the "lessThanOrEqualToConstant". But I can't get it to work. I've tried this: meetingFormView.translatesAutoresizingMaskIntoConstraints = false let constraintWidth = NSLayoutConstraint( item: meetingFormView, attribute: NSLayoutAttribute.width, relatedBy:

Self referencing foreign-key constraints and delete

南楼画角 提交于 2019-12-10 03:58:21
问题 what is the recommended way to handle self-referencing foreignkey constraints in SQL-Server? Table-Model: fiData references a previous record in tabData. If i delete a record that is referenced by fiData , the database throws an exception: "The DELETE statement conflicted with the SAME TABLE REFERENCE constraint "FK_tabDataPrev_tabDataNext". The conflict occurred in database "MyDataBase", table "dbo.tabData", column 'fiData'" if Enforce Foreignkey Constraint is set to "Yes". I don't need to

Is there a way to avoid row deletion on an specific table using constrains or triggers?

让人想犯罪 __ 提交于 2019-12-10 02:45:02
问题 Is there a way to avoid row deletion on an specific table using constrains? I'd like to (for example) deny row deletion if the id is 0,1 or 2 This is in order to avoid users deleting master accounts for an application, and I'd like to avoid it even if someone tries it (by mistake) using sql directly. Thanks! EDIT: The whole idea of this question is not to touch the application. It's not a matter of security, I just need to know if It's possible to do what I asked with constrains or any other

What is point of constraint validation @Null?

旧街凉风 提交于 2019-12-10 01:30:19
问题 I was checking list of available constraints in javax.validation package and I noticed that there is an annotation @Null which force the field to be null. I do not understand what is point of adding it to my field if I already know it should be null. For example look at this class: public class MyClass{ @NotNull private String myString1; @Null private String myString2; // getter setters... } @NotNull completely makes sense. I do not expect myString1 to be null. but @Null makes myString2

How to place unique contraint on multiple column

蹲街弑〆低调 提交于 2019-12-10 00:56:54
问题 EmpID DeptID 1 1 1 2 2 1 3 2 4 5 5 2 1 1 2 1 I would like to have a constraint that will make sure that the pair of field is always unique ,such data as last two shown in the example should not be insert-able into the table .in the above table please note that last two rows are duplicates ,I would like to prevent such data from occuring . How do I achieve this in sqlserver 2005.Thanks 回答1: ALTER TABLE <YourTable, sysname, Emp> ADD CONSTRAINT <YourConstraintName, sysname, uix> UNIQUE