我有一个hibernate和JSF2应用程序进入部署服务器并突然在异常中抛出org.hibernate.AssertionFailure:null id.我将立即提供堆栈跟踪和代码,但这里首先是四个重要问题:
这只发生在部署服务器上(在Windows Sever 2008上运行的Jboss和MySql).它不会发生在我的开发机器上(在Windoes 7 Pro上运行的Tomcat和MySql),也不会发生在暂存环境中(在Linux上运行的Jboss和MySql) .)
研究这个,似乎人们在尝试插入对象时会出现此错误.但是当我做一个简单的查询时,我得到了错误.(实际上,各种不同的查询随机地在几个页面上弹出错误.)
错误只会偶尔出现.如果我做Jboss重启它会消失,但一段时间后会返回.此外,它不一致,有些点击它在那里,而其他人则没有.即使它命中,当我对页面进行简单的刷新时它也会返回.
我正在使用c3p0(下面的配置)
知道发生了什么事吗?
代码详情:
这发生在地址对象上.这是完整的hbm:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping package="com.idex.auctions.model">
<class name="Address" table="address" lazy="true">
<id name="addressID" column="AddressID">
<generator class="native"/>
</id>
<property name="street" column="street"/>
<property name="city" column="city"/>
<property name="zip" column="zip"/>
<property name="state" column="state"/>
<property name="region" column="region"/>
<property name="country" column="country"/>
<many-to-one name="user"
class="com.idex.auctions.model.User"
column="userid"
unique="true"
cascade="save-update"/>
</class>
</hibernate-mapping>
Run Code Online (Sandbox Code Playgroud)
Java类是直截了当的:
public class Address implements Serializable {
private static final long serialVersionUID = 7485582614444496906L;
private long addressID;
private …
Run Code Online (Sandbox Code Playgroud) 第一次点击后,JSF URL似乎没有变化,仅在第二次点击之后.例如,当导航home.jsf
到时auction.jsf
,显示的页面已经存在,auction.jsf
但浏览器地址栏中的URL保持不变home.jsf
,直到我第二次点击Auction链接.为什么会这样?有没有办法禁用它,并让网址正确显示?
我正在将css集成到我的JSF2应用程序中,并且有些东西不能使用这些字体.这是我尝试的方式:
字体在WebContent/resources/fonts中(在Eclipse上.)在同一目录中我有一个stylesheet.css文件,我声明了这样的字体:
@font-face {
font-family: 'TitilliumText22LRegular';
src: url('titilliumtext22lregular-webfont.eot');
src: url('titilliumtext22lregular-webfont.eot?#iefix') format('embedded-opentype'),
url('titilliumtext22lregular-webfont.woff') format('woff'),
url('titilliumtext22lregular-webfont.ttf') format('truetype'),
url('titilliumtext22lregular-webfont.svg#TitilliumText22LRegular') format('svg');
font-weight: normal;
font-style: normal;
}
Run Code Online (Sandbox Code Playgroud)
我在我的应用程序的header.xhtml中连接到样式表:
<h:outputStylesheet library="fonts" name="stylesheet.css"/>
Run Code Online (Sandbox Code Playgroud)
尝试连接到此的css类元素位于resources/css中,称为style.css.班级本身:
.time {
font: 19px 'TitilliumText22LRegular';
text-transform: uppercase;
line-height: 1.8;
white-space: nowrap;
}
Run Code Online (Sandbox Code Playgroud)
总之,我可以说这应该工作.但事实并非如此.我究竟做错了什么?
我需要在JSF 2应用程序的页面上显示一个下载文件的链接.现在,问题是该文件包含的数据取决于创建时对数据库的全新外观.但我想要做的是创建它并给用户一个链接,以便在一个动作中下载它.
这在两个操作中非常简单:使用按钮生成文件,并将其替换为生成文件后下载文件的链接.
那么问题是,这可以通过一次单击commandLink来完成吗?
编辑,遵循BalusC的评论如下.这是我要做的事情的具体细节,到目前为止已经完成了.我在xhtml中有这个:
<h:panelGroup rendered="#{!bean.showLinkToExcelFile()}">
<h:form>
<td><h:commandButton value="Generate list of your Bids for download" action="#{bean.createBidsList()}"/></td>
</h:form>
</h:panelGroup>
<h:panelGroup rendered="#{bean.showLinkToExcelFile()}">
<td><a href="#{bean.findBidsListFileName()}">Download Your Bids</a></td>
</h:panelGroup>
Run Code Online (Sandbox Code Playgroud)
这有效.该按钮创建一个excel文件,将其保存到某个位置,并更新数据库中的文件名.然后链接提供文件.但这对用户来说是一个两步过程.我希望它只是一步.所以一个链接,例如:
<a href="#{bean.findBidsListFileName()}">Download Your Bids</a>
Run Code Online (Sandbox Code Playgroud)
或者,最有可能的是,jsf commandLink将在后端创建excel文件,将其保存到/ resources/location,并在用户的计算机上无缝打开"保存"对话框.