nullable

@NotNull and @Nullable, contradicting java annotations

此生再无相见时 提交于 2019-12-11 05:34:48
问题 It happened to me that I accidentally did this: @javax.annotation.Nullable @javax.validation.constraints.NotNull The compiler didn't complain and everything seemed to work well. Now I am wondering what is internally happening when two or more annotations contradict each other. Furthermore, does the order matter? Is this @Nullable @NotNull the same than this? @NotNull @Nullable How is this working for annotations in general? Who wins? EDIT: I am looking for a general answer, not necessarily

EF Core insert null value to nullable column that has default value

拈花ヽ惹草 提交于 2019-12-11 03:08:58
问题 I am curious about specific scenario in SQL when using EF Core. For example there is a column that allows null and at the same time has defalut value, it is unusual situation but that is not the issue here. Question is about technical possibility. [SomeId] [uniqueidentifier] NULL DEFAULT (newsequentialid()) And in Application there is Entity(Code First) which has appropriate Property public Guid? SomeId { get; set; } The problem is how to Insert this Entity into DB so that SomeId would have

Nullable “scalar navigation properties” in EF 4.0: Mapping a non-nullable column from a separate database table to a nullable scalar entity property?

核能气质少年 提交于 2019-12-10 22:06:27
问题 Using Entity Framework version 4.0 (or any other version that is compatible with .NET 4.0), I want to map this existing relational database schema: to this logical object model: which I have tried setting up as follows: (I hope the German captions won't be too disorienting.) Entity Framework gives me this error: Error 3031: Problem in mapping fragments …: Non-nullable column FooBs.B in table FooBs is mapped to a nullable entity property. In the logical model, B ought to be nullable. However,

Oracle: Dynamically set all NOT NULL columns in a Table to allow NULL

混江龙づ霸主 提交于 2019-12-10 21:34:48
问题 I have a table with 75+ columns in it. Almost all of the columns have the NOT NULL constraint. If do a giant alter table modify statement (with every column in there), I get an error saying something along the lines of "You can't set this field to NULL, because it already is NULL" I have to do this for several tables, and so would prefer to have a dynamic solution. Can I dynamically find all of the columns that are NOT NULL, and set them to NULL? I've seen several similar questions like this,

How to use generic and Nullable<T> types in Dapper for materialization?

狂风中的少年 提交于 2019-12-10 20:51:41
问题 I have this call: public IObservable<T> Subscribe(object topic, string service, string connectionString, string query) { try { this.connection.ConnectionString = connectionString; this.connection.Open(); this.connection.Query<T>(query, new { transactionid = topic }).ToObservable().Subscribe(message => this.subject.OnNext(message)); return this.subject; } catch (Exception e) { this.subject.OnError(e); return this.subject; } finally { this.subject.OnCompleted(); this.connection.Close(); } }

PHP + PDO: Bind null if param is empty

牧云@^-^@ 提交于 2019-12-10 19:27:51
问题 I'm trying this (and all PoST var are treated before user send it, no SQL Injection worries): $stmt = $con->prepare($sql); $stmt->bindParam(":1", $this->getPes_cdpessoa()); $stmt->bindParam(":2", $this->getPdf_nupessoa_def()); When any of those vars are NULL, PDO cries and don't let execute my statement, and on my Table, i DO allow these fields beign nullables. Is there any way to check if the values are empty, pdo just bind NULL to then (and i mean, a smart way instead if(empty($_POST[

Kotlin equivalent for Optional::map in Java8

﹥>﹥吖頭↗ 提交于 2019-12-10 18:43:52
问题 Do you know if there is a shortcut for: if (x == null) null else f(x) For Java Optional you can just do: x.map(SomeClass::f) 回答1: Kotlin utilizes its own approach to the idea of Option , but there're map , filter , orElse equivalents: val x: Int? = 7 // ofNullable() val result = x ?.let(SomeClass.Companion::f) // map() ?.takeIf { it != 0 } // filter() ?: 42 // orElseGet() I ended up writing a full comparison here: 回答2: You can use let in this case, like this: fun f(x : Int) : Int{ return x+1

C# Nullable in conditional statement [duplicate]

隐身守侯 提交于 2019-12-10 18:39:50
问题 This question already has answers here : Nullable types and the ternary operator: why is `? 10 : null` forbidden? [duplicate] (9 answers) Closed 6 years ago . Why do we need explicit cast in second statement? bool? a = null; bool b = false; bool c = true; 1.) if(b || c) a = b; else a = null; 2.) a = (b || c)?(Nullable<bool>)b:null; 回答1: The conditional operator is an expression, thus it needs a return type - also both cases have to have the same return type. In your case, there is no way of

Detect nullable type

拟墨画扇 提交于 2019-12-10 18:17:15
问题 Is it possible to detect a Nullable type (cast into an object) when it is null? Since Nullable<T> is really a struct I think it should be possible. double? d = null; var s = GetValue(d); //I want this to return "0" rather than "" public string GetValue(object o) { if(o is double? && !((double?)o).HasValue) //Not working with null return "0"; if(o == null) return ""; return o.ToString(); } 回答1: http://msdn.microsoft.com/en-us/library/ms228597(v=vs.80).aspx Objects based on nullable types are

Nullable<> types are a BCL, CLR, or both implementation?

我怕爱的太早我们不能终老 提交于 2019-12-10 17:55:49
问题 Some time ago I thought that Nullable<> value types are classes, encapsulating value types and a bool to HasValue. With some implicit cast operador for null, just implemented at BCL. But being a struct, how this can be achieved? Nullable<> struct is "special" for CLR? 回答1: Nullable<T> is defined as a normal struct, but there's special hooks within the CLR to box/unbox an instance of [mscorlib]System.Nullable`1 to null according to the HasValue property. There's more details on this here 回答2: