Questions tagged [notnull]

This tag refers to an object or type that is not null (none).

Use this tag for questions related to not-null types or objects (i.e. detecting them, handling them, etc.).

295 questions
6
votes
3 answers

When would you use optional>

I was reading References, simply and got to the part talking about using optional references. One of the reasons Herb gives to avoid optional is because those situations can be "represented about equally well by optional>" I'm…
janovak
  • 1,531
  • 2
  • 12
  • 22
6
votes
1 answer

Replace NaT in a dataframe with a previous variable

how can I replace NaT from a dataframe with a date/variable that was created (setup) before? I got the following dataframe: Date Name CF 0 NaT Peter -10 0 2017-12-14 Peter -20 1 NaT …
Newbie
  • 451
  • 1
  • 3
  • 14
6
votes
5 answers

Check not null in Java

Imagine I have, say, XML-generated entity in Java that holds some data I need. For example: 175 So if I need an engine power, I, followed by the best practices of business…
6
votes
1 answer

MySQL Insert Select Doesn't Enforce NOT NULL Constraint

I'm having an issue with MySQL 5.6 InnoDb ignoring a NOT NULL foreign key when running an INSERT INTO xxx (col) SELECT .... The constraint is enforced properly when running insert statements in other formats. Foreign key checks are enabled, and…
adam
  • 113
  • 1
  • 1
  • 8
6
votes
2 answers

How can I change my existing column in MariaDB to Not Null?

Message : You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ''country_of_residence_id' INTEGER NOT NULL' Statement : ALTER TABLE address ALTER COLUMN…
Suisse
  • 3,467
  • 5
  • 36
  • 59
6
votes
2 answers

NotNull not working, Column(nullable = false) working

I have a Spring Entity with a field annotated with @NotNull from javax.validation.constraints @Entity public abstract class IdentifiableNamedEntity { @NotNull @Column(unique = true) private String name; } The issue is that if a set a…
Manu
  • 4,019
  • 8
  • 50
  • 94
6
votes
1 answer

Mark method call that it always returns not null result

Scala compiler has -Xcheck-null which tries to check if there are any potential null pointer dereference in runtime. It's ok for me, but I get too much false positives, i.e. suppose I define logger : private final val LOGGER: Logger =…
uthark
  • 5,333
  • 2
  • 43
  • 59
6
votes
2 answers

prevent autoincrementing integer primary key?

I have a sqlite table (sqlite version 3.7.3) where nulls inserted into the primary key column are being undesirably auto-incremented: sqlite> CREATE TABLE foo(bar INTEGER NOT NULL PRIMARY KEY); sqlite> INSERT INTO foo(bar) VALUES(NULL); sqlite>…
bigdogwillfeed
  • 140
  • 1
  • 8
5
votes
1 answer

Generate `Objects.requireNonNull` lines for each argument automatically in IntelliJ?

Might there be a way in IntelliJ 2018 to auto-generate the lines of code checking for null values passed in any argument? I want IntelliJ to change this: // ----------| Constructor |----------------------------------- public DailyProduct (…
Basil Bourque
  • 303,325
  • 100
  • 852
  • 1,154
5
votes
2 answers

IDEA doesnt want to use NotNull from javax, but instead use org.jetbrains

I was setuping my project when saw this on @NotNull annotation in my DTOs Not 'javax.validation.constraints.NotNull' but 'org.jetbrains.annotations.NotNull' would be used for code generation I have import javax.validation.constraints.NotNull; But…
5
votes
2 answers

Understanding Optionals.orElse

I am trying to learn Java 8 feature Optional. I am confused about how Optional.orElse is working. Here is what i have tried: public class OptionalsExample { public static void main(String[] args) { Name userName = new Name(); …
silentsudo
  • 6,730
  • 6
  • 39
  • 81
5
votes
1 answer

MySQL - Foreign key on delete set null in not null field

This is probably a trivial question, but I'm still a little clumsy when it comes to foreign key constraints so I wanted to make sure. Let's say I have a table countries with the fields country_id (PK) and name, and a table cities with the fields…
Bobe
  • 2,040
  • 8
  • 29
  • 49
5
votes
1 answer

Eclipse @NonNull annotations with Maven and Jenkins

I would like to use the new @NonNull annotation from Eclipse Juno but the project I'm working on is based on Maven and is deployed with Jenkins. Is there any way that my annotations won't break the code for other developers who don't use Eclipse and…
Konrad Höffner
  • 11,100
  • 16
  • 60
  • 118
4
votes
1 answer

Where does the processing of an annotation happen?

I've been reading about annotations lately, and I'm a bit confused. I've used the annotation @NotNull but I don't really know how it checks if the variable is not null. No where in the code do I see anything checking values for null. That makes…
gsgx
  • 12,020
  • 25
  • 98
  • 149
4
votes
0 answers

Rider shows a warning that a variable can be null even if an attribute is present that it is not null

I created a regular TryGet method, but added the NotNullWhen(true) attribute to its out parameter, which means that the variable cannot be null if the method returns true. When using the method further, Rider writes a warning that the variable can…
Nikita
  • 41
  • 1
1 2
3
19 20