有没有人有一个如何用log4j2记录hibernate sql参数的例子?我知道如何使用log4j 1.x登录它们,但我无法使用log4j的2.0 beta 3版本(迄今为止的最后一个版本).
谢谢.
结构如下:
{
"_id" : "79f00e2f-5ff6-42e9-a341-3d50410168de",
"bookings" : [
{
"name" : "name1",
"email" : "george_bush@gov.us",
"startDate" : ISODate("2013-12-31T22:00:00Z"),
"endDate" : ISODate("2014-01-09T22:00:00Z")
},
{
"name" : "name2",
"email" : "george_bush@gov.us",
"startDate" : ISODate("2014-01-19T22:00:00Z"),
"endDate" : ISODate("2014-01-24T22:00:00Z")
}
],
"name" : "Hotel0",
"price" : 0,
"rating" : 2
}
Run Code Online (Sandbox Code Playgroud)
现在,我想生成一份报告,告诉我有多少预订,按预订月份分组(假设只有预订开始日期很重要),并按酒店评级分组.
我希望答案是这样的:
{
{
rating: 0,
counts: {
month1: 10,
month2: 20,
...
month12: 7
}
}
{
rating: 1,
counts: {
month1: 5,
month2: 8,
...
month12: 9
}
}
...
{ …Run Code Online (Sandbox Code Playgroud) 我有一个Web应用程序,我希望主页包含一个登录表单,以及其他数据.如果用户选择登录,则应将其重定向到另一个页面(例如login_success.jsp).我的问题是:我可以使用j_security_check机制登录,或者唯一的方法是使用托管bean来处理登录?
我的主页看起来像这样:
....
<form action="j_security_check" method="POST" name="loginForm">
<h:panelGrid columns="2">
<h:outputLabel id="userNameLabel" for="j_username" value="#{label.home_username}:" />
<h:inputText id="j_username" autocomplete="off" />
<h:outputLabel id="passwordLabel" for="j_password" value="#{label.home_password}:" />
<h:inputSecret id="j_password" autocomplete="off" />
<h:panelGroup>
<h:commandButton type="submit" value="Login" />
<h:commandButton type="reset" value="Clear" />
</h:panelGroup>
</h:panelGrid>
</form>
...
Run Code Online (Sandbox Code Playgroud)
如果我按下登录按钮,我得到 - > HTTP状态400 - 对表单登录页面的无效直接引用.很明显,j_security_check机制不知道在哪里"重定向",因为我以前没有请求过受保护的资源.
我正在开发2个android应用程序,它们是我服务器的客户端.我无法在我的Android手机上安装这两个应用程序.我将第一个应用程序安装到手机上,一切正常.然后,当我尝试在手机上安装第二个应用程序时,我收到应用程序将替换另一个应用程序(第一个)的消息,然后我收到以下错误:
未安装应用程序:已安装具有相同冲突签名的现有包名称.
我提到我为每个应用程序创建了一个单独的密钥库文件,在android官方签名应用程序指南中导出它们,然后对它们进行zipaligned.
那么OS认为它是一个单一的应用程序?但实际上有2个不同的应用程序.我究竟做错了什么?
请帮我.我面临这个错误3天.我在网上搜索了所有的例子,但我无法弄明白.
这些是我的文件:
在struts.xml
...
<action name="menu" class="com.struts.actions.MenuAction" method="asdf">
<result name="success" type="tiles">struts2tiles.home</result>
</action>
...
Run Code Online (Sandbox Code Playgroud)
menu2.jsp
....
<body>
<s:form action="menu">
<s:checkboxlist label="What's your favor color" list="colors" name="colors" />
<s:submit value="submit" name="submit" />
</s:form>
</body>
Run Code Online (Sandbox Code Playgroud)
MenuAction
public class MenuAction extends ActionSupport {
private ArrayList<String> colors;
private String yourColor;
public ArrayList<String> getColors() {
return colors;
}
public void setColors(ArrayList<String> colors) {
this.colors = colors;
}
public String getYourColor() {
return yourColor;
}
public void setYourColor(String yourColor) {
this.yourColor = yourColor;
}
public String asdf() …Run Code Online (Sandbox Code Playgroud) 我从事多线程Java应用程序,它是一个提供REST服务的Web服务器,每秒大约1000个请求.我有一个关系数据库,我使用hibernate来访问它.该数据库每秒约有300-400个请求.从多线程的角度来看,我想知道DAO模式是否正确.
所以,有一个BaseModel类看起来像这样:
公共类BaseModelDAO {
protected Session session;
protected final void commit() {
session.getTransaction().commit();
}
protected final void openSession() {
session = HibernateUtil.getSessionFactory().openSession();
session.beginTransaction();
}
Run Code Online (Sandbox Code Playgroud)
}
然后我为数据库中的每个表都有一个DAO类:
公共类ClientDAOHibernate扩展BaseModelDAO实现ClientDAO {
private Logger log = Logger.getLogger(this.getClass());
@Override
public synchronized void addClient(Client client) throws Exception {
try {
openSession();
session.save(client);
commit();
log.debug("client successfully added into database");
} catch (Exception e) {
log.error("error adding new client into database");
throw new Exception("couldn't add client into database");
} finally {
session.close();
}
}
@Override
public synchronized Client …Run Code Online (Sandbox Code Playgroud) I'm just curious, what happens if there are used both inheritance and aggregation in the same maven application? This is the application structure:
my-project-app
Now, in app's pom.xml, I declare jar and war projects as modules, and in the same time the the poms from both modules declare the app pom as their parent. It is create some kind of redundancy here, isn't it?
What is the best solution for this case?