小编com*_*tta的帖子

Hibernate缓存策略

我该如何决定CacheConcurrencyStrategy使用哪个?

  • NonstrictReadWriteCache,
  • ReadOnlyCache,
  • ReadWriteCache,
  • TransactionalCache.

我阅读了https://www.hibernate.org/hib_docs/v3/api/org/hibernate/cache/CacheConcurrencyStrategy.html,但没有详细解释.

java orm hibernate ehcache second-level-cache

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

Java foreach循环:for(Integer i:list){...}

当我使用JDK5时如下

ArrayList<Integer> list = new ArrayList<Integer>();  
     for (Integer i : list) { 

      //cannot check if already reached last item

   }
Run Code Online (Sandbox Code Playgroud)

另一方面,如果我只是使用一个 Iterator

ArrayList<Integer> list = new ArrayList<Integer>();
  for (Iterator i = list.iterator(); i.hasNext();) {

          //i can check whether this is last item
          if(i.hasNextItem()){
          }

    }
Run Code Online (Sandbox Code Playgroud)

如何检查我是否已经使用了最后一项 for (Integer i : list) {

java foreach iterator

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

JPA主键自动生成

我的主要密钥实体如下所示

@GeneratedValue(strategy= GenerationType.TABLE)
private Long id;
Run Code Online (Sandbox Code Playgroud)

当我跑,我得到错误

无法获取或更新下一个值;嵌套异常是org.hibernate.exception.SQLGrammerException:无法获取或更新下一个值

但是当我改变的时候

@GeneratedValue 
private Long id;
Run Code Online (Sandbox Code Playgroud)

没有错误抛出.我想在oracle db 上为每个表生成唯一的主键.

java orm hibernate jpa oracle10g

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

eclipse on maven项目警告'DTD或XML架构'

Description Resource    Path    Location    Type
No grammar constraints (DTD or XML schema) detected for the document.   TEST-net.kindleit.gae.example.server.MessageRepositoryTest.xml  /projecttest-gae-example/target/surefire-reports    line 1  XML Problem
No grammar constraints (DTD or XML schema) detected for the document.   appengine-web.xml   /projecttest-gae-example/src/main/webapp/WEB-INF    line 1  XML Problem
No grammar constraints (DTD or XML schema) detected for the document.   appengine-web.xml   /projecttest-gae-example/target/projecttest-gae-example-1.0-SNAPSHOT/WEB-INF    line 1  XML Problem
No grammar constraints (DTD or XML schema) detected for the document.   datastore-indexes-auto.xml  /projecttest-gae-example/WEB-INF/appengine-generated    line 1  XML Problem
No grammar constraints (DTD or XML schema) …
Run Code Online (Sandbox Code Playgroud)

java eclipse google-app-engine maven-2 maven

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

如何添加json库

我是新来的python,在我的Mac上,当我发出命令

User:ihasfriendz user$ python main.py
Traceback (most recent call last):
  File "main.py", line 2, in <module>
    import json
ImportError: No module named json
Run Code Online (Sandbox Code Playgroud)

我在json上得到错误.如何添加这个库?我正在使用2.5(默认附带豹纹)

python macos json python-2.5

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

JPA @Version:如何使用它?

@Entity
public class Person {
    @Id
    @GeneratedValue(strategy=GenerationType.IDENTITY)
    private Long id;

    private int salary;

    @Version
    private long version;

    // ...getters and setters
}
Run Code Online (Sandbox Code Playgroud)
  1. 是否需要为其创建setter/getter version
  2. 使用Hibernate持久保存此实体时,我不需要手动设置此值,对吧?
  3. 为了在Spring中使用乐观并发检查,还需要配置hibernateTemplate.saveOrUpdate什么?是否支持所有数据库?
  4. 如何对这个实体进行单元测试?在我的数据库中,显示版本字段的所有记录的值都为0
  5. 调用会hibernateTemplate.saveOrUpdate每次增加版本值吗?

java spring dao hibernate jpa

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

java inputstream print来控制内容

sock = new Socket("www.google.com", 80);
       out  = new BufferedOutputStream(sock.getOutputStream());
       in   = new BufferedInputStream(sock.getInputStream());
Run Code Online (Sandbox Code Playgroud)

当我尝试打印出"in"内的内容,如下所示

 BufferedInputStream bin = new BufferedInputStream(in);
 int b;
 while ( ( b = bin.read() ) != -1 )
 {

     char c = (char)b;         

     System.err.print(""+(char)b); //This prints out content that is unreadable.
                                   //Isn't it supposed to print out html tag?
 }
Run Code Online (Sandbox Code Playgroud)

java servlets httpwebrequest

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

使用firebug在JavaScript中查找内存泄漏?

是否有任何Firefox附加组件可用于查找部分JavaScript导致内存泄漏?

javascript firefox jquery firebug

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

spring认证提供程序VS认证处理过滤器

spring认证提供程序和认证处理过滤器都需要注册authenticationManager吗?

身份验证提供程序我可以使用custom-authentication-provider标记

但是什么是不同的Spring认证提供程序和认证处理过滤器?

java spring spring-mvc spring-security

13
推荐指数
2
解决办法
5330
查看次数

Hibernate的Transformers.aliasToBean()方法

 Query query =  getHibernateTemplate().getSessionFactory().getCurrentSession().createSQLQuery(
                 "select proj_employee.employee_no as employeeNo, ...
 .setResultTransformer(Transformers.aliasToBean(User.class));
Run Code Online (Sandbox Code Playgroud)

在User.class中,属性employeesNo需要是大写字母吗?

private String EMPLOYEENO; 
//get/set for EMPLOYEENO
Run Code Online (Sandbox Code Playgroud)


如果我改变了EMPLOYEENO小信,这是行不通的.任何人都可以解释为什么变量名必须全是大写字母?

java hibernate

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