小编Sam*_*ser的帖子

Using xml config instead of @Type annotation in hibernate with Spring Data JPA

My company uses java 7 with hibernate 3 with spring 3 in one of it's legacy projects. All of the spring and hibernate configs are in xml files and they don't use annotations.

For some customers the database is oracle and for others it's db2.

In oracle we have problem when the data type is Date and we use java.util.date with time. The problem was located at the binding level when Hibernate prepared the query.

java.util.Date is converted to …

java oracle hibernate spring-data-jpa

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

检查两个未知类型的对象是否相等,比较所有字段

我需要定义一个方法来比较同一类型的两个不同对象.对象的类型不是特定的.对象可能是DLL类型,因此我无法覆盖Equals方法.我必须通过反思来做到这一点.如果对象的所有成员都是基本类型,则此代码有效.但是当对象具有非原始字段时,它不起作用.我怎么能通过反思来做到这一点?

public bool Equals(object obj1, object obj2)
{
    List<FieldInfo> fieldInfos =  obj1.GetType().GetFields().ToList();
    return (fieldInfos.Select(fieldInfo => new {fieldInfo, type = fieldInfo.GetType()})
        .Where(@t => @t.type.IsPrimitive || @t.type == typeof(string) || @t.type == typeof(Decimal))
        .Select(@t => @t.fieldInfo)).All(fieldInfo => fieldInfo.GetValue(obj1).Equals(fieldInfo.GetValue(obj2)));
}
Run Code Online (Sandbox Code Playgroud)

c# reflection equality

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

Windows服务应该在启动时加载表单

如何在Windows服务的OnStart事件中加载"登录表单"?!我知道Windows服务与UI不兼容.但是我需要在不使用Windows启动的情况下这样做..这可能吗?如何?非常感谢.

c# windows-services login windows-authentication

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