小编ber*_*tie的帖子

Hibernate:现实世界中的模式导出?

我很好奇为我的下一个项目完全使用模式导出.我认为它是一种非常有用的方法来真正处理对象而不是底层数据库.只需创建并注释模型,然后将其导出即可.

但是从先创建表格然后再创建模型对象的习惯来看,我对使用模式导出完全有疑问.这主要是因为我真的深入研究了休眠.但我仍然很好奇这个区域列表在使用模式导出时是否会出现问题.请分享你的经历..

  1. 表之间的关系
  2. 代理/复合主键支持
  3. 当我只想从一些模型中导出一些模型时,重新导出将重新创建所有数据库?
  4. 其他我此时无法想到的

谢谢

java hibernate

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

JSF 2重用JPA实体中定义的验证?

让我们从一个例子开始:


在我的JPA实体中

public class User {
    @Pattern("^([0-9a-zA-Z]([-.\w]*[0-9a-zA-Z])*@([0-9a-zA-Z][-\w]*[0-9a-zA-Z]\.)+[a-zA-Z]{2,9})$", message="invalidEmailResourceBundleKey")
    private String email;

    @Min(5, message="minimumResourceBundleKey")
    private int age;

...
}
Run Code Online (Sandbox Code Playgroud)

在我的JSF Bean中

public class UserBean {
    private User user;

    // do i have to redefine it here, since it's already a part of the user ?
    @@Pattern("^([0-9a-zA-Z]([-.\w]*[0-9a-zA-Z])*@([0-9a-zA-Z][-\w]*[0-9a-zA-Z]\.)+[a-zA-Z]{2,9})$") 
    public String getEmail() {
        return user.getEmail();
    }
    public void setEmail(String s) {
        user.setEmail(s);
    }

    // do i have to redefine it here, since it's already a part of the user ?
    @Min(5, message="minimumResourceBundleKey")
    public int …
Run Code Online (Sandbox Code Playgroud)

jsf jpa bean-validation jsf-2 jpa-2.0

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

使用CompositeComponent的javax.el.PropertyNotFoundException?

我目前正在尝试构建一个复合组件,这就是我如何使用我的组件:


包括它 xmlns:albert="http://java.sun.com/jsf/composite/albert"


这是用法示例

<albert:infoButton
    infoId="infoSingleRecord"
    params="transDateFrom transDateTo"
    mappingMethod="#{tBrowseBean_ConfirmedRPB.mapSendInfoSingleRecord}" />
Run Code Online (Sandbox Code Playgroud)

这是放在resources/albert/infoButton.xhtml中的组件

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"  
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:p="http://primefaces.prime.com.tr/ui"
    xmlns:fn="http://java.sun.com/jsp/jstl/functions"
    xmlns:composite="http://java.sun.com/jsf/composite">

    <composite:interface>
        <composite:attribute name="infoId" required="true" />
        <composite:attribute name="params" />
        <composite:attribute name="mappingMethod" method-signature="java.lang.String action()" />
    </composite:interface>

    <composite:implementation>
        <p:commandButton 
            process="@this #{cc.attrs.params}"
            actionListener="#{cc.attrs.mappingMethod}"
            update="#{cc.attrs.infoId}Panel"
            oncomplete="#{cc.attrs.infoId}Dialog.show()" 
            image="ui-icon ui-icon-search" />
    </composite:implementation>
</html>
Run Code Online (Sandbox Code Playgroud)

但运行它,当单击infoButton时,此异常跟踪显示在我的catalina.out日志文件中:

Apr 25, 2011 10:08:43 AM javax.faces.event.MethodExpressionActionListener processAction
SEVERE: Received 'javax.el.PropertyNotFoundException' when invoking action listener '#{cc.attrs.mappingMethod}' for component 'j_idt71'
Apr 25, 2011 10:08:43 AM …
Run Code Online (Sandbox Code Playgroud)

jsf composite-component jsf-2 propertynotfoundexception

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

在mongodb中实现具有总页面的嵌入式分页

我查看了一个与我的嵌入式分页情况相关的旧问题.尽管带有切片的嵌入式分页工作正常,但总页面解决方案仍然缺失,我想知道是否有可能在服务器端获得注释的总大小.

有没有办法查询或统计服务器上的嵌入式阵列的大小,而无需将整个文档提取到我的应用程序并手动计数?

我不介意为此做2个查询,1个用于分页评论,1个用于获取评论总数.如果我可以在一个查询中执行此操作,那将是惊人的.

顺便说一下,我正在使用java驱动程序和spring-data mongodb.

请分享你的想法.谢谢 !

mongodb mongodb-java spring-data

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

Facelet:<ui:insert>不能放在属性值问题中

我目前正在使用JSF 2.0中的facelets进行实验.

我目前有一个案例,其中2个facelets使用公共网格定义,仅在bean名称,列表名称,标题,网格id等某些区域有所不同.

所以我的想法是:

  1. 为该网格创建模板,利用<ui:insert>在使用它的页面之间可能不同的区域
  2. 这2页,利用模板,为模板提供参数 <ui:define>

这是我的gridTemplate.xhtml:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"  
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:p="http://primefaces.prime.com.tr/ui"
    xmlns:fn="http://java.sun.com/jsp/jstl/functions">

<h:head>
    <title>#{msgs.title}</title>
</h:head>

<h:body>
    <ui:composition template="/template/masterlayout.xhtml">
        <p:dataTable id="<ui:insert name='gridId' />" var="rpb"
            value="#{<ui:insert name='bean' />.<ui:insert name='list' />}">
            <f:facet name="header">
                <h3><ui:insert name='title' /></h3>
            </f:facet>

            .....

            <f:facet name="footer">
                #{fn:length(<ui:insert name='bean' />.<ui:insert name='list' />)} records<br />
            </f:facet>
        </p:dataTable>
    </ui:composition>
</h:body>
</html>
Run Code Online (Sandbox Code Playgroud)

这是使用网格模板的facelet之一:

<ui:composition template="gridTemplate.xhtml">
    <ui:define name="gridId">grid</ui:define>
    <ui:define name="bean">myBean</ui:define>
    <ui:define name="list">myList</ui:define>
    <ui:define name="title">my message !</ui:define>
</ui:composition>
Run Code Online (Sandbox Code Playgroud)

这个实验最终得到: …

jsf facelets jsf-2

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

调试spring mvc视图渲染时间

我目前正在使用Spring MVC 3.x,并使用freemarker视图解析器.

最近我一直想知道在作为响应发送回来之前将视图翻译成html所需的执行时间.如果这方面的事情很慢,我想做调音,这就是为什么我需要一些数字.

在普通的freemarker模式下,我实际上可以在它们之间执行简单的System.currentTimeMillis()来找出执行时间:

long start = System.currentTimeMillis();
// this could be slow or fast depending on the caching used
Template temp = cfg.getTemplate(ftlName);
...
temp.process(model, myWriter); // depends on the writer
System.out.printf("done in %s ms", System.currentTimeMillis() - start);
Run Code Online (Sandbox Code Playgroud)

但是,当使用spring mvc的freemaker视图渲染时,我该怎么做呢?

freemarker spring-mvc

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