null

hibernate cascade - update child to null

一笑奈何 提交于 2019-12-11 03:39:55
问题 I have a one to many relationship between event and session. I'd like cascade to update event fk in session to null when i delete the corresponding event. Any clue how to do this? Thanks and advance. 回答1: Hibernate or JPA unfortunately don't have a Cascade type 'SET to NULL' but you should be able to do it with @PreRemove on the one side (Owner): @OneToMany(mappedBy="whatever") public List<SomeEntity> getSomeEntity(){ return someEntity; } @PreRemove public void onDelete(){ for(SomeEntity se :

Revert to default value in mongoose if field is set to null

三世轮回 提交于 2019-12-11 03:36:22
问题 I am using mongoose with nodeJS. Consider the following schema: var PersonSchema = new mongoose.Schema({ "name": {type: String, default: "Human"}, "age": {type: Number, defualt:20} }); mongoose.model('Person', PersonSchema); var order = new Order({ name:null }); This creates a new Person document with name set to null. { name:null, age: 20 } Is there anyway to check if the property being created/updated is null and if it is null set it back to default. The following declaration var order =

why dim of colMeans/rowMeans return null?

感情迁移 提交于 2019-12-11 03:33:21
问题 I am new to R. I have the following code sigma1 = matrix(c(2,0,0,1),2,2) mu1 = matrix(c(0,10),2,1) x1 = t(mvrnorm(n = 5, mu1, sigma1)) print(rowMeans(x1)) print(dim(colMeans(x1))) and for some reason I get NULL for dimension of row/col means. 回答1: 'as.matrix' turns the vector 'colMeans(x1)' into a matrix. Then the dimensions are 5 and 1, as expected: library(rockchalk) sigma1 = matrix(c(2,0,0,1),2,2) mu1 = matrix(c(0,10),2,1) x1 = t(mvrnorm(n = 5, mu1, sigma1)) print(rowMeans(x1)) print(dim

MariaDB Insert BLOB Image

血红的双手。 提交于 2019-12-11 03:23:10
问题 What I want to do? I want to insert a picture into a MariaDB database using the command line, using the LOAD_FILE fuction. What's wrong? I always get a NULL return. I don't want a solution like: This is bad style and I haven't seen this so far - try to store the full path! I want to store this picture in this database and not the path. System mysql Ver 15.1 Distrib 10.1.17-MariaDB, for Linux (x86_64) using readline 5.1 ArchLinux 4.7.2-1-ARCH A picture called Test.jpg (817KB) under /home/user

json_encode for mysql query returns some null columns of some rows, but the columns aren't null

蓝咒 提交于 2019-12-11 03:22:22
问题 I'm creating a little php file to get mysql rows for my android application. to retrieve each single row i use: $q=mysql_query($sql, $this->conn) or die (mysql_error()); while($e=mysql_fetch_assoc($q)) { $output[]=$e; } print(json_encode($output)); but sometimes it returns me an inconsistent output. Here's an example: The row: id=1 (correct) - name="name1" (correct) - price=200 (correct) - price2=null (correct) - area=null (NOT CORRECT) because area has a value of "Centro Città" .. and so on.

Pattern for optional-parameters in Scala using null

拈花ヽ惹草 提交于 2019-12-11 03:19:39
问题 I have a function which takes optional parameters. However, these are not Option[?] but can be either set or null: private def div(id: String = null, cssClass: String = null): JQuery = { val optId = Option(id) val optCssClass = Option(cssClass) ... // deal with optId and optCssClass using the Scala-way™ ... } I am using "null", which I know should be avoided like the plague. However, it allows me to write code like this: div(id = "someId") // no cssClass div(id = "otherId", cssClass =

GetProcAddress returns NULL

主宰稳场 提交于 2019-12-11 03:17:33
问题 I have to use a simple function from a DLL; I am able to load the library but GetProcAddress returns NULL. I think I understood name mangling but maybe I'm doing something wrong. Thanks (Code follows, asap I'll add other information required): mydll.h #ifdef MYDLL_EXPORTS #define MYDLL_API extern "C" __declspec(dllexport) #else #define MYDLL_API extern "C" __declspec(dllimport) #endif MYDLL_API void testFunction(void); MYDLL_API LRESULT CALLBACK mouseProc(int nCode, WPARAM wParam, LPARAM

Checking SQL MAX() Function returning null

泄露秘密 提交于 2019-12-11 03:11:54
问题 My problem is if my table is empty or the column on which I am using max function does not have the value I have specified, then why is sqlDataReader.hasRows TRUE? It is giving a null record...how do I solve this problem?? Thanks in advance. 回答1: An aggregate function like MAX() will always return one row per group. In your case, your group is the whole table. Therefore you get a one row resultset with the MAX value. Since you don't have data in your table, the MAX value is undefined,

Handling null in Linq

守給你的承諾、 提交于 2019-12-11 03:09:16
问题 I am new to linq, and this keeps popping on a null volume field. The file is unpredictable, and it will happen so I would like to put a 0 in where there is an exception. any quick and easy way to do it? var qry = from line in File.ReadAllLines("C:\\temp\\T.txt") let myRecX = line.Split(',') select new myRec() { price = Convert.ToDecimal( myRecX[0].Replace("price = ", "")) , volume = Convert.ToInt32(myRecX[1].Replace("volume =", "")), dTime = Convert.ToDateTime( myRecX[2].Replace("timestamp ="

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