constraints

Fluent NHibernate primary key constraint naming conventions

白昼怎懂夜的黑 提交于 2019-12-04 22:28:23
Is there any way to create a naming convention for my primary key constraints in Fluent NHibernate? I know you can name foreign key constraints, but it does not appear possible to name the primary key constraint. James Gregory from FNH says... No, that's not supported through NHibernate, so we can't support it either. http://groups.google.com/group/fluent-nhibernate/browse_thread/thread/9ea7155407d33772 来源: https://stackoverflow.com/questions/1358043/fluent-nhibernate-primary-key-constraint-naming-conventions

Solving the Zebra puzzle (aka. Einstein puzzle) using the clpfd Prolog library

孤街醉人 提交于 2019-12-04 21:45:20
问题 I have been given an exercise to solve the zebra puzzle using a constraint solver of my choice, and I tried it using the Prolog clpfd library. I am aware that there are other more idiomatic ways to solve this problem in Prolog, but this question is specifically about the clpfd package! So the specific variation of the puzzle (given that there are many of them) I'm trying to solve is this one: There are five houses The Englishman lives in the red house The Swedish own a dog The Danish likes to

Java Play 2 - How would you define a maxlength constraint from config parameter?

核能气质少年 提交于 2019-12-04 20:07:20
Using Play 2.3 (Java), I'd like to use a parameter from application.conf as a value for a constraint. Something like: public class Some { @Constraints.MaxLength(Play.application().configuration().getInt("some.text.maxlength", 1000)) public String text; } But of course I can't do this because the annotation parameter must be a constant. What would be the approach, in Java, to bypass this? Should I use a custom validator? Or is there another option? Any help appreciated. As you discovered you can't use it via annotations, but fortunately you can write own constraints and read the application

Questions about implementing Domain class relationships & constraints in Grails

扶醉桌前 提交于 2019-12-04 19:47:52
Using ArgoUML, I very quickly created this trivial representation of a few Domain classes (Person, Store, Product) and their relationships. I'm struggling with the implementation of the relationships. Below was my initial approach for the Person domain, but it seems that I am missing something important. class PersonToPerson { Person from Person to String relation static constraints = { relation(inList:["Friend to", "Enemy of", "Likes", "Hates"]) } static belongsTo = [ Person ] } class Person { String firstName String secondName . . . static hasMany= [ personToPerson:PersonToPerson,

R function to calculate nearest neighbor distance given [inconsistent] constraint?

笑着哭i 提交于 2019-12-04 19:11:51
I have data consisting of tree growth measurements (diameter and height) for trees at known X & Y coordinates. I'd like to determine the distance to each tree's nearest neighbor of equal or greater size . I've seen other SE questions asking about nearest neighbor calculations (e.g., see here , here , here , here , etc.), but none specify constraints on the nearest neighbor to be searched. Is there a function (or other work around) that would allow me to determine the distance of a point's nearest neighbor given that nearest point meets some criteria (e.g., must be equal to or greater in size

How to constrain the number of records allowed in an SQL table?

▼魔方 西西 提交于 2019-12-04 19:08:17
Say I have two tables, Parent and Child. Parent has a MaxChildren (int) field and Child has an Enabled (bit) field and a ParentID (int) field linking back to the parent record. I'd like to have a constraint such that there can't be more than MaxChildren records for each parent where Enabled = 1. This would mean that any attempt to insert or update any record in the Child table will fail if it goes over the applicable MaxChildren value, or any attempt to lower MaxChildren to below the current number of applicable Child records will fail. I'm using MS SQL Server, but I'm hoping there's a

Why does a direct cast fail but the “as” operator succeed when testing a constrained generic type?

扶醉桌前 提交于 2019-12-04 18:16:46
问题 ``I've run across an interesting curiosity when compiling some C# code that uses generics with type constraints. I've written a quick test case for illustration. I'm using .NET 4.0 with Visual Studio 2010. namespace TestCast { public class Fruit { } public class Apple : Fruit { } public static class Test { public static void TestFruit<FruitType>(FruitType fruit) where FruitType : Fruit { if (fruit is Apple) { Apple apple = (Apple)fruit; } } } } The cast to Apple fails with the error: "Cannot

JQuery UI Slider with Multiple handles: How to stop the handles from crossing?

一曲冷凌霜 提交于 2019-12-04 17:49:58
I'm developing a quick solution that uses a Slider with multiple handles to define widths for a dynamic layout. I've attempted to use both ExtJS3 and the latest JQuery UI. In ExtJS, you can constrain the handles so the don't cross over each other, and it's quite an intuitive approach to the UI I need, however there are reasons why I would rather not use ExtJS for one 'island' in a sea of JQuery. So, does anyone know of a secret attribute, or a bit of code that constrains multiple handles in the JQuery slider ? For clarity: if you have a slider with 2 handles, one at 40 and one at 60; the

How to edit constraint in code

放肆的年华 提交于 2019-12-04 17:49:28
问题 I have a web page that start with a width constrain of 100. When the user click a button i want to change the constrain to : 200. I tried this: NSLayoutConstraint *constrain = [NSLayoutConstraint constraintWithItem:self.webPage attribute:NSLayoutAttributeWidth relatedBy:NSLayoutRelationEqual toItem:self.webPage attribute:NSLayoutAttributeWidth multiplier:1 constant:100]; [self.webPage addConstraint:constrain]; But this throws out this exception : "Unable to simultaneously satisfy constraints.

UITableView when changing constraint which effects height of cell after dequeueing, end up with broken constraints

两盒软妹~` 提交于 2019-12-04 17:29:08
This code block tries to get to the heart of the problem. If, after dequeuing a cell (via configure ), the constraints are changed so that the cell height is changed, then you end up with a broken constraints warning ( Unable to simultaneously satisfy constraints ...). However, it displays correctly. import UIKit class ViewController: UIViewController { @IBOutlet var tableView: UITableView! override func viewDidLoad() { super.viewDidLoad() tableView.delegate = self tableView.dataSource = self tableView.registerClass(Cell.self, forCellReuseIdentifier: "cell") tableView.estimatedRowHeight = 55.0