小编Bea*_*ast的帖子

Hibernate的本机查询和缓存机制

我有一个关于Hibernate缓存机制的问题.我在文章中读到了hibernate中本机SQLquery的执行,使缓存的所有区域无效,因为hibernate对它将影响哪个特定实体一无所知.这里缓存的所有区域意味着我们在谈论二级缓存的各个区域或两级缓存(第一级缓存,二级缓存)还是仅二级缓存或仅第一级缓存?

java orm caching hibernate jpa

9
推荐指数
1
解决办法
8541
查看次数

什么是属性节点

XPath 数据模型中的属性节点是什么?某个特定节点何时会成为属性节点?

如果有人可以提供属性节点的示例,那将非常有帮助。

xml

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

构造函数参数解析

我最近开始在3.2版本上工作.我试图理解构造函数参数解析,以防何时通过构造函数注入传递依赖项.我创建了以下示例.

package com.springinaction.springidol;

public interface Performer {
    void perform();
}
package com.springinaction.springidol;

public class Juggler implements Performer {

    private int beanBags=3;
    private String name;

    public Juggler(){
    }

    public Juggler(String name,int beanBags){
        System.out.println("First constructor gets called");
        this.beanBags=beanBags;
        this.name=name;
    }

    public Juggler(int beanBags,String name){
        System.out.println("Second constructor gets called");
        this.beanBags=beanBags;
        this.name=name;
    }

    public void perform(){
    System.out.println("JUGGLING "+beanBags+name+" BEANBAGS");
    }
}
Run Code Online (Sandbox Code Playgroud)

请查看下面我使用的spring配置文件的实例.

<?xml version="1.0" encoding="UTF-8" ?>

<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">

<bean id="duke" class="com.springinaction.springidol.Juggler">
    <constructor-arg value="Jinesh" />
    <constructor-arg value="77" />
</bean>
Run Code Online (Sandbox Code Playgroud)

在上面的场景中,调用的构造函数是第一个构造函数.但之后我稍微更改了xml文件并为两个参数添加了type属性.

<?xml version="1.0" …
Run Code Online (Sandbox Code Playgroud)

java spring

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

Jshell / env命令不允许在Classpath中设置多个Jar文件

嗨,我在Windows 10操作系统上使用JDK11,而我正在使用的Jshell版本是11.0.1。

我正在尝试执行各种Jshell命令,并被卡在以下命令的执行中

我有一个示例程序,该示例程序使用多个JAR文件Employee.jar和spring-context-5.1.3.jar文件中的类。

登录到Jshell之后,我正在使用以下命令在Jshell中设置类路径,但它会引发错误

jshell> /env -class-path D:\JshellClassPath\Employee.jar:D:\JshellClassPath\spring-context-5.1.3.jar
|  File 'D:\JshellClassPath\Employee.jar:D:\JshellClassPath\spring-context-5.1.3.jar' for '--class-path' is not found.
Run Code Online (Sandbox Code Playgroud)

如果我仅设置一个Jar文件并执行上述命令,则可以正常工作,但是为什么我不能设置多个Jar文件/ env命令?

java jshell java-11

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

找不到Hibernate JPA项目的persistence.xml

嗨,我是Hibernate JPA的新手.我正在使用eclipse kepler 4.3.2并创建一个简单的java项目.我没有使用maven来编译项目.我有以下persistence.xml位于项目的src文件夹中

<?xml version="1.0" encoding="UTF-8"?>
<persistence xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    version="2.0"
    xmlns="http://java.sun.com/xml/ns/persistence"
    xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd" >
    <persistence-unit name="rawsjpa" transaction-type="RESOURCE_LOCAL">
        <!-- <class>com.mumz.test.hibernatesearch.entitybeans.MHSBookEntityBean</class>
        <class>com.mumz.test.hibernatesearch.entitybeans.MHSBookShelfEntityBean</class> -->
        <properties>
            <property name="hibernate.show_sql" value="true"/>
            <property name="hibernate.connection.driver_class" value="oracle.jdbc.OracleDriver"/>
            <property name="hibernate.connection.password" value="Test2@cdn"/>
            <property name="hibernate.connection.url" value="jdbc:oracle:thin:@(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=rschcdndb1d.nam.nsroot.net)(PORT=1526))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=OSRDD1)))"/>
            <property name="hibernate.connection.username" value="AW"/>
            <property name="hibernate.dialect" value="org.hibernate.dialect.Oracle8iDialect"/>
        </properties>
    </persistence-unit>
</persistence>
Run Code Online (Sandbox Code Playgroud)

我正在尝试创建EntityManager的以下示例主程序.

import javax.persistence.EntityManager;
import javax.persistence.Persistence;

/**
 * 
 */

/**
 * @author jp48346
 *
 */
public class TestRawsConnection {

    public static void main(String args[]){
        EntityManager entityManager = Persistence.createEntityManagerFactory("rawsjpa").createEntityManager();
        if(entityManager!=null){
            System.out.println("************* EntityManager is obtained *****************");
        }
    }

}
Run Code Online (Sandbox Code Playgroud)

下面是eclipse项目.classpath文件 …

java eclipse hibernate jpa

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

Spring MVC 4.1 RedirectAttributes 无法正常工作

我是 Spring MVC 的新手。我正在使用 Spring 版本 4.1.6 并在 tomcat 7 上为开发环境部署了我的两个 Web 应用程序 A 和 B。但是在实际生产环境中,应用A会部署在weblogic上,应用B会部署在websphere上。下面是在开发环境中发生的场景。

应用程序A 在test 目录中有testrequest.jsp 页面。下面是jsp 页面的代码。

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>    
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Test Media Request</title>
</head>
<body>
<h2>Fill your form123!</h2>
<form:form method="post" commandName="testobj" action="http://localhost:8080/b/createtestrequest.test">
    <table>
        <tr>
            <td>Enter your name:</td>
            <td><form:input  path="requestId" /></td>
            <td><form:errors path="requestId" cssStyle="color: #ff0000;"/></td>
        </tr>
        <tr>
             <td><input type="submit" name="submit" value="Submit"></td>
        </tr>
    </table>
</form:form>
</body>
</html> …
Run Code Online (Sandbox Code Playgroud)

java spring spring-mvc

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

标签 统计

java ×5

hibernate ×2

jpa ×2

spring ×2

caching ×1

eclipse ×1

java-11 ×1

jshell ×1

orm ×1

spring-mvc ×1

xml ×1