null

Eclipse bug? Switching on a null with only default case

I was experimenting with enum, and I found that the following compiles and runs fine on Eclipse (Build id: 20090920-1017, not sure exact compiler version): public class SwitchingOnAnull { enum X { ,; } public static void main(String[] args) { X x = null; switch(x) { default: System.out.println("Hello ...

How to insert null value for numeric field of a datatable in c#?

Consider My dynamically generated datatable contains the following fileds Id,Name,Mob1,Mob2 If my datatable has this it get inserted successfully, Id Name Mob1 Mob2 1 acp 9994564564 9568848526 But when it is like this it gets failed saying, Id Name Mob1 Mob2 1 acp 9994564564 The given value of type String from...

Need help to build a PL/SQL Query

Hi, I'm having scenario to which a sql query need to be built. I tried to come up with a efficient query, but could not find a clear way of doing this. My scenario is as follows: I'm having TABLE_A and TABLE_B ,where FIELD_AB will definitely be a filed of TABLE_A, however, there can be exist FIELD_AB in TABLE_B. I need to retrieve val...

HashMap null key

HashMap allows one null key and any number of null values. what is the use of it? ...

Are Maybes a good pattern for scala?

For a while I have been struggling to integrate scala with java methods that might return null. I came up with the following utility which helps a lot: // produce an Option, nulls become None object Maybe { def apply[T](t:T) = if (t==null) None else Some(t) } Maybe(javaClass.getResultCouldBeNull()).map( result => doSomeWork(resul...

I can't insert NULL values into datetime2 fields in SQL Server

Hi! I'm using CakePHP. When trying to insert a null value into a field it turns into 1900-01-01 00:00:00. Here's a sample of my code: $this->save(array( 'date_signed' => null )); What seems to be the error and how do I fix it? Thanks in advance! ...

java.lang.NullPointerException

Hi every one, I do a condition with a value when it is null and when it is not null. The time where this value is null i got the java.lang.NullPointerException. How could i deal with this in order to dismiss this exception. I need the condition when the value is null and when it is not. Thanks for help. ...

How do I insert the null value in a Boolean attribute when using Hibernate?

I have a class with a Boolean attribute. When I instantiate and persist this class, the Boolean attribute is stored with the "false" value instead of the expectable "null". How can I set a Boolean attribute to "Null"? ...

Is there a way to know in VB.NET if a handler has been registered for an event?

In C# I can test for this... public event EventHandler Trigger; protected void OnTrigger(EventArgs e) { if (Trigger != null) Trigger(this, e); } Is there a way to do this in VB.NET? Test for null I mean? MORE INFO I forgot to mention. I have classes written in C# but I am writing my unit tests in VB.NET. I am tryin...

Checking for nulls in ASP.NET MVC Controllers

Another opinion question: What is the proper (in your opinion) to check for nulls in an MVC controller. For instance, if you have an edit controller that fetches a record from the db based on an id, what do you do if that record is not found? I found this article, but I'm not sure I like that method. Do you just check for it with an ...

Can Microsoft store three-valued fields in a single bit?

I'm completely ignorant of SQL/databases, but I was chatting with a friend who does a lot of database work about how some databases use a "boolean" field that can take a value of NULL in addition to true and false. Regarding this, he made a comment along these lines: "To Microsoft's credit, they have never referred to that kind of field...

Why does typeof null misbehave in switch statements?

It is commonly known that typeof null returns "object". However, I have a piece of code that looks like this: switch(typeof null){ case "object": 1; default: 3; } This code returns 3. Why does "object" as returned by typeof null not cause the first branch of the case statement to be executed? ...

What is the difference between NULL in C++ and null in Java?

I've been trying to figure out why C++ is making me crazy typing NULL. Suddenly it hits me the other day; I've been typing null (lower case) in Java for years. Now suddenly I'm programming in C++ and that little chunk of muscle memory is making me crazy. Wikiperipatetic defines C++ NULL as part of the stddef: A macro that expands ...

Why is NULL/0 an illegal memory location for an object?

I understand the purpose of the NULL constant in C/C++, and I understand that it needs to be represented some way internally. My question is: Is there some fundamental reason why the 0-address would be an invalid memory-location for an object in C/C++? Or are we in theory "wasting" one byte of memory due to this reservation? ...

How do I pass null as the default instance of an Interface using StructureMap?

I'd like to pass null as the default instance of my IFarmManager class using StructureMap. I've currently got the following in my Global.asax: ObjectFactory.Initialize(x => { x.ForRequestedType<IFarmManager>().TheDefault.Is.Object(null); }; However, an ArgumentNullException is thrown at runtime: Value cannot be null. Parameter n...

SQL Server 2005 - Using Null in a comparison

This is more of a question to satisfy my own curiosity. Given the following statement: DECLARE @result BIT SET @result = CASE WHEN NULL <> 4 THEN 0 ELSE 1 END PRINT @result Why do i get back "1" instead of "0" Changing it to: DECLARE @result BIT SET @result = CASE WHEN NULL IS NULL ...

getting Null pointer exception

Hi I am getting this message on emulator when I run my android project: The application MediaPlayerDemo_Video.java (process com.android.MediaPlayerDemo_Video) has stopped unexpectedly. Please try again I am trying to run the MediaPlayerDemo_Video.java given in ApiDemos in the Samples given on developer.android.com. The code is ...

What is the value of NULL in SQL Server ?

Hi, I know NULL is not zero... nor it is empty string. But then what is the value of NULL... which the system keeps, to identify it? ...

Missing Java error on conditional expression?

With methods test1() and test2(), I get a Type Mismatch Error: Cannot convert from null to int, which is correct; but why am I not getting the same in method test3()? How does Java evaluate the conditional expression differently in that case? (obviously, a NullPointerException will rise at runtime). Is it a missing error? public class ...

Map null column as 0 in a legacy database (JPA)

Using Play! framework and it's JPASupport class I have run into a problem with a legacy database. I have the following class: @Entity @Table(name="product_catalog") public class ProductCatalog extends JPASupport { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) public Integer product_catalog; @OneToOne @Jo...