问题列表 - 第6234页

如何在JPA/JPQL中过滤集合?

我有两个实体:

@Entity
public class Customer  implements java.io.Serializable {
...
    @OneToMany(fetch=FetchType.EAGER, mappedBy="customer")
    private Set<CustomerOrder> customerOrders;
...


@Entity
public class CustomerOrder  implements java.io.Serializable {
....        

    private double cost;

    @ManyToOne
    @JoinColumn(name="CUST_ID")
    public Customer customer;
...
Run Code Online (Sandbox Code Playgroud)

现在在我的JPQL中,我希望以CustomerOrder.cost> 1000返回那些客户.例如,有三个客户A,B和C.A有两个订单,成本分别为1000和2000.B有三个订单,成本分别为2000,3000和500.C有一个成本= 500的订单.现在我想得到三个客户:A只返回成本= 2000的订单; B返回2000和3000的订单; C返回一个空订单集合.

但以下将始终返回完整集合:

select c from Customer c, in(c.customerOrders) o where o.cost>1000
Run Code Online (Sandbox Code Playgroud)

我怎么能在JPQL或Hibernate中做到这一点?

hibernate jpa jpql

6
推荐指数
1
解决办法
2万
查看次数

SDL/C++ OpenGL程序,如何阻止SDL捕获SIGINT

我正在将SDL用于在Linux上运行的OpenGL应用程序.我的问题是SDL正在捕获SIGINT并忽略它.这是一个痛苦,因为我正在通过屏幕会话开发,我不能用CTRL-C杀死正在运行的程序(计算机运行的程序连接到投影仪并且没有输入设备).

是否有标志或我可以传递给SDL的东西,以便它不捕获SIGINT?我真的只是希望程序在收到信号时停止(即当我按下ctrl-c时).

c++ linux signals sdl

9
推荐指数
3
解决办法
3267
查看次数

Qt Creator如何塑造Eclipse CDT?

Qt Creator看起来像一个很好的IDE.我一直在使用Eclipse CDT,虽然有点小马车,它可以完成这项工作.

Qt Creator是否具有与Eclipse CDT相同的功能?

eclipse qt-creator

16
推荐指数
2
解决办法
1万
查看次数

SQLCommand.ExecuteScalar() - 为什么抛出System.NullReferenceException?

任何人都可以注意到以下功能可能出现的问题:

public string Login(string username, string password)
    {
        string result = "";
        string select = "SELECT user_id FROM [user] WHERE username = @username AND password = @password";
        SqlConnection conn = new SqlConnection(connectionString);
        SqlCommand cmd = new SqlCommand(select, conn);
        cmd.Parameters.AddWithValue("username", username);
        cmd.Parameters.AddWithValue("password", password);
        int userID = 0;
        try
        {
            conn.Open();
            userID = (int)cmd.ExecuteScalar();
            if(userID > 0)
            {
                result = addSession(userID);
            }
        }
        catch(Exception ex)
        {
            string sDummy = ex.ToString();
        }
        return result;
    }
Run Code Online (Sandbox Code Playgroud)

不知道为什么行`userID =(int)cmd.ExecuteScalar(); 抛出一个例外.

谢谢

.net sqlcommand exception

3
推荐指数
1
解决办法
6328
查看次数

使用UIImagePickerController选择图像后,照片库视图停留在屏幕上

通过照片库中的UIImagePickerController接口选择图片后,即使我在imagePickerController调用dismissModelViewControllerAnimated:didFinishPickingImage:editingInfo,照片库视图也会保持显示状态.

有没有人见过这个?这些是我正在使用的三种相关方法:

- (IBAction)choosePictureFromLibrary:(id)sender {
    if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypePhotoLibrary]) {
        UIImagePickerController* picker = [[UIImagePickerController alloc] init];
        picker.delegate = self;
        picker.allowsImageEditing = YES;
        picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
        [self presentModalViewController:picker animated:YES];
        [picker release];
    }
    else {
        UIAlertView* alert = [[UIAlertView alloc] initWithTitle:@"Error accessing Photo Library" message:@"This device does not support a Photo Library." delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
        [alert show];
        [alert release];
    }
}


- (void)imagePickerController:(UIImagePickerController*)picker didFinishPickingImage:(UIImage*)image editingInfo:(NSDictionary*)editingInfo {   
    UIAlertView* alert = [[UIAlertView alloc] initWithTitle:@"Picture picked!" message:@"You picked a picture!" …
Run Code Online (Sandbox Code Playgroud)

iphone objective-c uiimagepickercontroller

4
推荐指数
1
解决办法
2389
查看次数

如何在C中的二叉搜索树中正确插入/删除?

我有点不得不把我以前的C问题暂停,因为现在这个问题更重要了......

我已经在二叉搜索树上编写了插入和删除函数,但删除函数不完整.我需要帮助的一些事情......

1)我的插入功能是好还是可以以某种方式改进?

2)我的删除功能没有删除具有左右子节点的节点.我在过去的几个小时里搜索过很多但是找不到合适的方法.

2.a)我应该如何删除具有2个子节点的节点?

2.b)与第一个问题一样,删除功能是好还是可以改进?这个我知道它可以因为我在那些ifs中重复了很多代码,但是我不知道如何改进它,我也需要帮助.

typedef struct sClientProfile *ClientProfile;
typedef struct sClientTree *ClientTree;

typedef struct sClientProfile {
    char *clientName;
    int clientAge;
    int clientNIF;
} nClientProfile;

typedef struct sClientTree {
    ClientProfile clientProfile;
    char *clientName;

    ClientTree leftTree;
    ClientTree rightTree;
} nClientTree;

void addClientToTree(ClientTree *cTree, ClientProfile cProfile) {
    if(!*cTree) {
        ClientTree new = (ClientTree)malloc(sizeof(nClientTree));

        if(!new) {
            perror("malloc");
        }

        new->clientName = strdup(cProfile->clientName);
        new->clientProfile = cProfile;

        new->leftTree = NULL;
        new->rightTree = NULL;

        *cTree = new;
    } else {
        if(strcmp((*cTree)->clientName, cProfile->clientName) …
Run Code Online (Sandbox Code Playgroud)

c search binary-tree insert

2
推荐指数
1
解决办法
2万
查看次数

更改TFS Build的位置

我有一个TFS构建服务器,其中发生CI和发布版本.构建过程在某个域帐户下运行,所有构建活动都在此用户的临时目录下运行.不幸的是,\ Users目录位于C:驱动器上,结果是空间不大.虽然构建保留策略非常严格,但是已经配置了足够的构建,这个空间变得非常稀缺.

机器上还有其他卷有足够的空间.

任何人都可以建议一种直接的方式来更改根构建目录吗?到目前为止,我一直在寻找TFS属性而没有太大的成功.

谢谢.

build-automation tfs

5
推荐指数
1
解决办法
7492
查看次数

makefile可以更新调用环境吗?

是否可以从makefile更新环境?我希望能够创建一个目标来为它们设置客户端环境变量.像这样的东西:

AXIS2_HOME ?= /usr/local/axis2-1.4.1
JAVA_HOME  ?= /usr/java/latest
CLASSPATH  := foo foo

setenv:
    export AXIS2_HOME
    export JAVA_HOME
    export CLASSPATH
Run Code Online (Sandbox Code Playgroud)

这样客户就可以做到:

make setenv all
java MainClass
Run Code Online (Sandbox Code Playgroud)

并且让它工作而不需要为java执行本身设置类路径.

或者我是否希望以错误的方式做到这一点并且有更好的方法?

linux makefile fedora

5
推荐指数
1
解决办法
7012
查看次数

你可以设计一个noscript元素吗?

是否可以noscript在CSS选择器中使用该元素?

noscript p {
    font-weight: bold;
}
Run Code Online (Sandbox Code Playgroud)

html css noscript

12
推荐指数
2
解决办法
9491
查看次数

asp.net MVC验证框架的选项

我正在考虑为我正在开始的ASP.net项目进行模型库验证的两个选项:

xVal(Steve Sanderson的项目)和Stephen Walther在此页面上使用的企业模块

我真的不太了解偏好,因为我还没有使用它们中的任何一个.有任何想法吗?

立即更新使用LinqToSql for ORM,但我愿意接受更改.

validation asp.net-mvc xval

2
推荐指数
1
解决办法
2382
查看次数