null

Null value objects in NHibernate

假如想象 提交于 2019-12-22 03:45:38
问题 I have a person entity containing an Address as a value object: public Person() { WithTable("Person"); Id(x => x.Id); Component<Address>(x => x.Address, a => { a.Map(x => x.Address1); a.Map(x => x.Address2); a.Map(x => x.Address3); a.Map(x => x.Town); a.Map(x => x.Postcode); }); } It states in the NHibernate docs that if all the properties of a value object (Address1, Address2 etc) are null, the entire component will be mapped as null (i.e. Person.Address will be null). This is giving me

Why check if (*argv == NULL)? [duplicate]

假如想象 提交于 2019-12-22 03:22:33
问题 This question already has answers here : When can argv[0] have null? (4 answers) Closed 2 years ago . In the data structures class that I am currently taking, we have been tasked with writing a web crawler in C++. To give us a head start, the professor provided us with a program to get the source from a given URL and a simple HTML parser to strip the tags out. The main function for this program accepts arguments and so uses argc/argv. The code used to check for the arguments is as follows: //

Java, Parse JSON Objects that I know are null

送分小仙女□ 提交于 2019-12-22 03:16:44
问题 I have an array of JSON objects. To parse these arrays and store the simply data type values, I have to make assumptions of the key names and store them accordingly. I also know that sometimes the key's values will be null. example {["promotion":null]} how would I parse this? If I try to access a key whose value is null, I get a JSONException. Now this makes sense, but even if I do if(myJSObject.getString("promotion")!=null) then I will still get JSON exception when it checks how would I do a

How to determine whether object reference is null?

怎甘沉沦 提交于 2019-12-22 01:59:00
问题 What is the best way to determine whether an object reference variable is null ? Is it the following? MyObject myObjVar = null; if (myObjVar == null) { // do stuff } 回答1: Yes, you are right, the following snippet is the way to go if you want to execute arbitrary code: MyObject myObjVar; if (myObjVar == null) { // do stuff } BTW: Your code wouldn't compile the way it is now, because myObjVar is accessed before it is being initialized. 回答2: The way you are doing is the best way if (myObjVar ==

How can JSON data with null value be converted to a dictionary

与世无争的帅哥 提交于 2019-12-22 01:24:55
问题 { "abc": null, "def": 9 } I have JSON data which looks like this. If not for null (without quotes as a string), I could have used ast module's literal_eval to convert the above to a dictionary. A dictionary in Python cannot have null as value but can have "null" as a value. How do I convert the above to a dictionary that Python recognizes? 回答1: You should use the built-in json module, which was designed explicitly for this task: >>> import json >>> data = ''' ... { ... "abc": null, ... "def":

Sort when values are None or empty strings python

蓝咒 提交于 2019-12-22 01:17:51
问题 I have a list with dictionaries in which I sort them on different values. I'm doing it with these lines of code: def orderBy(self, col, dir, objlist): if dir == 'asc': sorted_objects = sorted(objlist, key=lambda k: k[col]) else: sorted_objects = sorted(objlist, key=lambda k: k[col], reverse=True) return sorted_objects Now the problem is that I occasionally have null values or empty strings when I try to sort and then it all breaks down. I'm not sure but i think that this is the exception that

Input value 0 = empty?

▼魔方 西西 提交于 2019-12-22 01:17:00
问题 I have a page where you register your dog, and I want all these fields to be required: $required_fields = array('name', 'age', 'gender', 'breed', 'size'); foreach ($_POST as $key => $value) { if (empty($value) && in_array($key, $required_fields) === true) { $errors[] = 'All fields marked with * are required.'; break 1; } } The problem is, that if someone enters 0 (which I instruct them to do if the dog is a puppy), the submission seems to read that field as empty (giving me this error). I

How to Nil a object in Swift

人盡茶涼 提交于 2019-12-22 01:13:02
问题 How to assign nil to an object in Swift. I'm getting error if assigned directly. 回答1: From Apple Documentation: nil cannot be used with nonoptional constants and variables . If a constant or variable in your code needs to work with the absence of a value under certain conditions, always declare it as an optional value of the appropriate type also very importante to notice: Swift’s nil is not the same as nil in Objective-C . In Objective-C, nil is a pointer to a nonexistent object. In Swift,

MySQL: how to prevent insertion of a row with all columns = NULL?

大兔子大兔子 提交于 2019-12-22 00:38:33
问题 In my MySQL table, every column by itself can be NULL, but there must be at least one column with a non-NULL value. At the moment, I am wrapping an insert statement in a stored procedure which prevents insertion of all-NULL rows, but that of course does not keep anyone from using native INSERT statements, circumventing my wrapper procedure. Is there a 'native' way to define the table with that constraint ? 回答1: Since MySQL doesn't enforce check constraints, you may want to emulate one with a

undefined method `collect' for nil:NilClass

拥有回忆 提交于 2019-12-21 19:56:27
问题 Can someone help me with this error? NoMethodError in Posts#create Showing C:/Users/User/Documents/website/app/views/posts/_form.html.erb where line #24 raised: undefined method `collect' for nil:NilClass Extracted source (around line #24): 23: <%= f.label :categoria %> 24: <%= f.select :categoria_id, @categoria.collect { |c| [ c.name, c.id ] } %> Trace of template inclusion: app/views/posts/new.html.erb My _form.html.erb <%= form_for(@post, :html => { :multipart => true }) do |f| %> <% if