小编Yuv*_*val的帖子

那里有没有重复的List实现吗?

我知道SortedSet,但在我的情况下,我需要一些实现List,而不是Set.那么在API或其他地方是否有实现?

实现自己应该不难,但我想为什么不先问问这里的人呢?

java collections list duplicates

80
推荐指数
5
解决办法
14万
查看次数

Hive在哪里存储HDFS中的文件?

我想知道如何找到Hive表与它们所代表的实际HDFS文件(或更确切地说,目录)之间的映射.我需要直接访问表文件.

Hive将文件存储在HDFS中的哪个位置?

hadoop hive hdfs

67
推荐指数
5
解决办法
13万
查看次数

使用Hibernate进行不区分大小写的搜索

我正在将Hibernate用于我的Java应用程序的ORM到Oracle数据库(不是数据库供应商很重要,我们可能有一天会切换到另一个数据库),我想根据用户提供的字符串从数据库中检索对象.例如,在搜索人员时,如果用户正在寻找居住在'fran'的人,我希望能够在旧金山为她的员工提供服务.

SQL不是我的强项,我更喜欢Hibernate的Criteria构建代码到硬编码字符串.任何人都可以指出我在正确的方向上如何在代码中执行此操作,如果不可能,硬编码的SQL应该如何?

谢谢,

Yuval = 8-)

sql select hibernate case-sensitive

49
推荐指数
3
解决办法
8万
查看次数

我从哪里开始学习图像处理和对象识别?

我有兴趣编写一些基本的计算机化对象识别应用程序,所以我想我需要一些图像处理算法的理论背景,以及一些用于决策能力的AI.

我是计算机科学专业的毕业生,有一天我打算获得硕士学位,希望能够进入这些领域.与此同时,我想先行一步,做一些自学.

所以我的问题是,我从哪里开始?我很欣赏正确方向的箭头,如果可能的话,还有一些链接.

theory image-processing computer-vision object-recognition

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

当我尝试更新/插入时,为什么Hibernate会尝试删除?

在我的应用程序中,我有这些Hibernate映射类型(一般情况):

class RoleRule {
  private Role role;
  private PermissionAwareEntity entity; // hibernate-mapped entity for which permission is granted
  private PermissionType permissionType; // enum

  @ManyToOne
  @JoinColumn(name = "ROLE_ID")
  public Role getRole() {
    return role;
  }
  public void setRole(Role role) {
    this.role = role;
  }

}

class Role {
  private Set<RoleRule> rules = new HashSet<RoleRule>(0);

  @OneToMany(cascade=CascadeType.ALL)
  @JoinColumn(name="ROLE_ID")
  public Set<RoleRule> getRules() {
    return rules;
  }
  public void setRules(Set<RoleRule> rules) {
    this.rules = rules;
  }

}
Run Code Online (Sandbox Code Playgroud)

所有课程都有equals() & hashCode()覆盖.

我的应用程序允许调整角色(仅限系统管理员,不用担心),以及其他字段,允许创建新的角色规则.创建新规则时,我尝试创建一个新RoleRule对象并将其插入角色的字段中 …

hibernate

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

更新集合中的对象

假设我的应用程序中有这种类型:

public class A {
  public int id;
  public B b;

  public boolean equals(Object another) { return this.id == ((A)another).id; }
  public int hashCode() { return 31 * id; //nice prime number }
}
Run Code Online (Sandbox Code Playgroud)

和一个结构.现在,我有一个类型的对象,并希望执行以下操作:Set<A>A

  • 如果我A在集合中,请更新其字段b以匹配我的对象.
  • 否则,将其添加到集合中.

所以检查它是否在那里很容易(contains),并且添加到集合也很容易.我的问题是:如何获得更新对象的句柄?接口Set没有get方法,我能想到的最好的方法是删除集合中的对象并添加我的对象.另一种,更糟糕的是,替代方法是使用迭代器遍历集合以尝试定位对象.

我很乐意接受更好的建议......这包括有效使用其他数据结构.

Yuval = 8-)

编辑:谢谢大家回答...不幸的是我不能'接受'这里的最佳答案,建议使用a Map,因为为此目的而根本改变集合的类型只会有点极端(这个集合是已经通过Hibernate映射...)

java set data-structures

16
推荐指数
4
解决办法
3万
查看次数

我怎样才能EasyMock演员表演?

我怎么能模拟演员表演.我对依赖对象进行了强制转换操作,它会转换为另一个依赖对象

SqlMapClient sqlMapClient;
SqlMapClientImpl sqlMapClientImpl = (SqlMapClientImpl) sqlMapClient 
Run Code Online (Sandbox Code Playgroud)

我正在嘲笑依赖的咒语ie SqlMapClientSqlMapClientImpl.但我需要知道如何使用EasyMock进行模拟.

任何帮助,将不胜感激.

java easymock

7
推荐指数
1
解决办法
2066
查看次数

testng - 在testng.xml中将列表作为参数传递

是否可以在testNG参数中传递列表.以下是示例代码

示例:尝试传递XML中的数字列表.不确定TestNG是否不支持此功能.或者我错过了什么?

 <suite name="Suite" parallel="none">  
     <test name="Test" preserve-order="false">  
         <parameter name="A" value="1"/>   
         <parameter name="B" value="2"/>   
         <parameter name="C" value="3"/>   
         <parameter name="D" value="{4,5}"/>   
         <classes>  
             <class name="TestNGXMLData"/>  
         </classes>  
     </test>  
 </suite>  
Run Code Online (Sandbox Code Playgroud)
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import com.thoughtworks.selenium.Selenium;
import static org.testng.Assert.assertTrue;
import org.testng.annotations.*;
import com.thoughtworks.selenium.*;

public class TestNGXMLData {

    @Test
    @Parameters(value = { "A", "B", "C", "D" })
    public void xmlDataTest(String A, String B, String C, ArrayList<String> ls) {

        System.out.println("Passing Three parameter to Test " + A + " and " + B + …
Run Code Online (Sandbox Code Playgroud)

java xml testng

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

hibernate.cache.region.factory_class hibernate.cfg.xml中必需的

我正在使用memcache作为Hibernate的二级缓存.我正在使用hibernate-memcached-1.2.4,spymemcached 2.8.0和hibernate 4.1.4.

但是当我尝试使用它时,它给了我错误的说法

    Initial sessionfactory creation failedorg.hibernate.cache.NoCacheRegionFactoryAvailableException: Second-level cache is used in the application, but property hibernate.cache.region.factory_class is not given, please either disable second level cache or set correct region factory class name to property hibernate.cache.region.factory_class (and make sure the second level cache provider, hibernate-infinispan, for example, is available in the classpath).
    Exception in thread "main" java.lang.ExceptionInInitializerError
        at Util.HibernateUtil.(HibernateUtil.java:16)
        at hibba.AccountDAOimpl.getAccount(AccountDAOimpl.java:23)
        at hibba.Connect.main(Connect.java:7)
    Caused by: org.hibernate.cache.NoCacheRegionFactoryAvailableException: Second-level cache is used in the application, but property hibernate.cache.region.factory_class is not given, …

memcached hibernate

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

用于hibernate 4的函数hibernate.cfg.xml

有没有人有hibernate 4的功能cfg文件示例?我在网上找到的所有参考文献都是低于v4,但是不起作用.我尝试粘贴我的文件的内容,但这个网站删除了hibernate配置标记.

所以这是出来的:

<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD//EN"
"http://www.hibernate.org/dtd/">

<hibernate-configuration xmlns="http://www.hibernate.org/xsd/hibernate-configuration">

  <session-factory> 

    <property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property> 
    <property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property> 
    <!-- Assume test is the database name --> 
    <property name="hibernate.connection.url">jdbc:mysql://localhost/foampile</property> 
    <property name="hibernate.connection.username">root</property> 
    <property name="hibernate.connection.password"></property> 
    <!-- List of XML mapping files --> 

    <mapping resource="SiteRecord.hbm.xml"/>

  </session-factory> 

</hibernate-configuration>
Run Code Online (Sandbox Code Playgroud)

一旦我改变了

<hibernate-configuration xmlns="http://www.hibernate.org/xsd/hibernate-configuration"
        xsi:schemaLocation="http://www.hibernate.org/xsd/hibernate-configuration hibernate-configuration-4.0.xsd"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
Run Code Online (Sandbox Code Playgroud)

我得到这个例外:

Caused by: org.xml.sax.SAXParseException; lineNumber: 9; columnNumber: 63; Attribute "xmlns" must be declared for element type "hibernate-configuration".
Run Code Online (Sandbox Code Playgroud)

但是指定了xmlns(xmlns ="http://www.hibernate.org/xsd/hibernate-configuration")

这是HIBERNATE 4.1中的一个BU ???

hibernate

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