我正在使用Hibernate Tools 3.2.1.GA和Spring 3.0.2版.我想将数据插入到Oracle(10g)数据库字段中clob,如下所示.
Clob c=Hibernate.createClob(request.getParameter("someTextFieldValueOnJSPPage");
pojoObj.setSomeClobProperty(c);
Run Code Online (Sandbox Code Playgroud)
它工作得很好但是当我尝试使用CKEditor插入数据流时, 我的JSP页面上的demo(CKEditor只是呈现HTML <textarea></textarea>元素)可能涉及格式化文本以及图像,flash等,它会抛出以下异常.
org.springframework.web.util.NestedServletException: Request processing failed; nested exception is org.hibernate.exception.GenericJDBCException: could not update: [model.Cms#1]
Run Code Online (Sandbox Code Playgroud)
org.hibernate.exception.GenericJDBCException: could not update: [model.Cms#1]
Run Code Online (Sandbox Code Playgroud)
java.sql.SQLException: operation not allowed: streams type cannot be used in batching
Run Code Online (Sandbox Code Playgroud)
如何解决该异常?这是Oracle驱动程序问题还是其他什么问题?我正在使用ojdbc14.jar,Oracle JDBC Driver version - 9.0.2.0.0.
更新:
使用该Clob类型的实体之一是
public class Cms implements java.io.Serializable
{
private BigDecimal cmsId;
private Clob aboutUs; //I'm currently dealing with this …Run Code Online (Sandbox Code Playgroud) 我收到一个java.util.List<Object[]>via JSON-rpc作为JavaScript数组,如下所示.
[
[1, 0.10, 1.00],
[2, 0.20, 2.00],
[3, 0.30, 3.00],
[4, 0.40, 4.00],
[5, 0.50, 5.00],
[6, 0.60, 6.00],
[7, 0.70, 7.00],
[8, 0.80, 8.00],
[9, 0.90, 9.00],
[10, 1.00, 10.00],
[11, 1.10, 11.00],
[12, 1.20, 12.00],
[13, 1.30, 13.00],
[14, 1.40, 14.00],
[15, 1.50, 15.00],
[16, 1.60, 16.00],
[17, 1.70, 17.00],
[18, 1.80, 18.00]
]
Run Code Online (Sandbox Code Playgroud)
我需要将同一个数组传递回服务器(在最后一个维度稍作修改).
我使用以下函数发回这个数组.
var request;
var timeout;
var itemsArray=[];
function insert()
{
if(!request)
{
var i=0;
$('input[name="txtCharge[]"]').each(function()
{
isNaN($(this).val())||$(this).val()===''?itemsArray[i][2]='':itemsArray[i][2]=eval(eval($(this).val()).toFixed(2));
i++;
}); …Run Code Online (Sandbox Code Playgroud) 我正在使用Google Guava库来执行诸如java.util.List<T>在Java EE 7应用程序中对a 进行排序和过滤的任务.
下面给出了java.util.List<T>基于CDI bean中的过滤器列表过滤a的示例.
@Named
@ViewScoped
public class Bean extends LazyDataModel<T> implements Serializable {
private static final long serialVersionUID = 1L;
private final class Filtering implements Predicate<T> {
private final Map<String, Object> filters;
public Filtering(Map<String, Object> filters) {
this.filters = filters;
}
@Override
public boolean apply(T p) {
if (p == null) {
return false;
}
Integer id = (Integer) filters.get("id");
if (id != null && !p.getId().equals(id)) {
return false;
}
BigDecimal size …Run Code Online (Sandbox Code Playgroud) 我跟随php mysql新手到忍者:
下面的表单模板
<form action="?" method="post">
<div>
<label for="joketext">Type your joke here:</label>
<textarea id="joketext" name="joketext" rows="3" cols="40"></textarea>
</div>
<div><input type="submit" value="Add"></div>
</form>
Run Code Online (Sandbox Code Playgroud)
PHP控制器的一部分:
if(isset($_POST['joketext'])) //insert block
{
try
{ //prepared starement
$sql = 'INSERT INTO joke SET
joketext = :joketext,
jokedate = CURDATE()';
Run Code Online (Sandbox Code Playgroud)
什么是'?' 做形式动作
希望听听有关从JSF UI编辑JPA实体的最佳实践的专家.
所以,关于这个问题的几句话.
想象一下,我有持久化对象MyEntity,我将其取出进行编辑.在DAO层我使用
return em.find(MyEntity.class, id);
Run Code Online (Sandbox Code Playgroud)
MyEntity在"父"实体上返回带有代理的实例 - 想象其中一个是MyParent.MyParent被提取为代理问候语@Access(AccessType.PROPERTY):
@Entity
public class MyParent {
@Id
@Access(AccessType.PROPERTY)
private Long id;
//...
}
Run Code Online (Sandbox Code Playgroud)
和MyEntity有它的参考:
@ManyToOne(fetch = FetchType.LAZY)
@LazyToOne(LazyToOneOption.PROXY)
private MyParent myParent;
Run Code Online (Sandbox Code Playgroud)
到现在为止还挺好.在UI中,我只是直接使用获取的对象而不创建任何值对象,并使用选择列表中的父对象:
<h:selectOneMenu value="#{myEntity.myParent.id}" id="office">
<f:selectItems value="#{parents}"/>
</h:selectOneMenu>
Run Code Online (Sandbox Code Playgroud)
一切都好,没有LazyInitializationException发生.但是当我保存对象时,我收到了
LazyInitializationException: could not initialize proxy - no Session
Run Code Online (Sandbox Code Playgroud)
在MyParent代理setId()方法.
如果我改变MyParent关系,我可以轻松解决问题EAGER
@ManyToOne(fetch = FetchType.EAGER)
private MyParent myParent;
Run Code Online (Sandbox Code Playgroud)
或使用获取对象left join fetch p.myParent(实际上我现在这样做).在这种情况下,保存操作正常,并且关系MyParent透明地更改为新对象.不需要执行其他操作(手动复制,手动参考设置).非常简单方便. …
如果这已经被覆盖我提前道歉,但我是新手,我看到有其他类似的帖子,但没有一个帮助所以我想可能还有另一个问题.
我有一个模态弹出窗口,它在Chrome中工作正常,但在IE中不起作用.问题似乎与线路有关
{ e.preventDefault(); }
Run Code Online (Sandbox Code Playgroud)
它给出以下错误.
错误:对象不支持属性或方法'preventDefault'
就像我说我是新手一样,我已经尝试过做其他日志中的说法,只要放一个圆形或者只是删除线但没有运气所以任何人都可以帮助我.
/* prevent default behaviour on click */
var e = this.browserEvent;
var tgt = this.triggeringElement;
/*e.preventDefault();*/
{ e.preventDefault(); }
/* Trigger JQuery UI dialog */
var horizontalPadding = 30;
var verticalPadding = 30;
$('<iframe id="modalDialog" src="' + $(tgt).attr("href") + '" />').dialog({
title: "IC v RT",
autoOpen: true,
width: 1050,
height: 700,
modal: true,
close: function(event, ui) {apex.event.trigger('#P28_AFTER_MODAL','select',''); $(this).remove();},
overlay: {
opacity: 0.5,
background: "black"}
}).width(1050 - horizontalPadding).height(700 - verticalPadding);
return false;
Run Code Online (Sandbox Code Playgroud) String a = "Hello\u200e";
String b = "Hello\u200f";
System.out.println("a = '" + a + "' and b = '" + b + "' are length "
+ a.length() + " and " + b.length()
+ ", equals() is " + a.equals(b));
Run Code Online (Sandbox Code Playgroud)
上面代码段中的代码生成以下输出.
a ='Hello'和b ='Hello'的长度为6和6,equals()为false
虽然控制台上显示的值a和值b都是Hello?,但a.equals(b)返回false.怎么样?
Joda Time的时区ID可以使用以下代码段显示.
Set<String> zoneIds = DateTimeZone.getAvailableIDs();
for(String zoneId:zoneIds) {
System.out.println(zoneId);
}
Run Code Online (Sandbox Code Playgroud)
但是如何显示相应的时区偏移量,时区ID和长名称,以便列表看起来如下所示?
(GMT-10:00) Pacific/Honolulu, Hawaii Standard Time
(GMT-10:00) Pacific/Johnston, Hawaii Standard Time
(GMT-10:00) Pacific/Fakaofo, Tokelau Time
(GMT-10:00) HST, Hawaii Standard Time
Run Code Online (Sandbox Code Playgroud)
需要将它们列在下拉框中以供选择.
以下代码段显示了名称,但显示的偏移看起来很糟糕.
Set<String> zoneIds = DateTimeZone.getAvailableIDs();
for (String zoneId : zoneIds) {
int offset = DateTimeZone.forID(zoneId).getOffset(new DateTime());
String longName = TimeZone.getTimeZone(zoneId).getDisplayName();
System.out.println("(" + offset + ") " + zoneId + ", " + longName);
}
Run Code Online (Sandbox Code Playgroud)
在它显示的长列表中,其中一些显示为,
(-36000000) Pacific/Honolulu, Hawaii Standard Time
(-36000000) Pacific/Johnston, Hawaii Standard Time
(-36000000) Pacific/Fakaofo, Tokelau …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用set标签在Struts2中创建一个动态变量
<s:set var="myNum" value="numConst" />
<s:set var="number" value="%{getText('@xxx.CommonConstant@'+#myNum)}" />
Run Code Online (Sandbox Code Playgroud)
numConst将返回从数据库中检索的动态值.例如,如果值为NINE则应为数字@xxx.CommonConstant@NINE
我已经在我的java类中设置了值,以便@xxx.CommonConstant@NINE返回9.
到目前为止,如果我使用的话,可以在文本标签中显示该值没有问题
<s:text name="%{getText(#number)}" />
Run Code Online (Sandbox Code Playgroud)
9当我尝试使用属性标记时,它会返回但显示不正确
<s:property value="%{getText(#number)}" />
<s:property value="%{#number}" />
<s:property value="#number" />
<s:property value="%{getText('%{getText(#number)}')}" />
Run Code Online (Sandbox Code Playgroud)
以上所有的例子都会给我价值@xxx.CommonConstant@NINE.我尝试从属性标记中获取值的原因是因为我想要复制正确的方法来显示值,以便我可以在if标签中使用它们,如下例所示:
<s:if test="#number == 9">
do something
</s:if>
Run Code Online (Sandbox Code Playgroud)
要么
<s:if test="%{getText(#number)} == 9">
do something
</s:if>
Run Code Online (Sandbox Code Playgroud)
CommonConstant:
package xxx;
public abstract class CommonConstant {
public static final int NINE = 9;
public static final int NINEONE = 91;
public static final double ADMIN_PGM …Run Code Online (Sandbox Code Playgroud) 在GlassFish(3.1.2.2b5)上运行的Java EE 6应用程序中,假设您有一个ConfigurationService,它读取一些属性文件并相应地分发属性值:
@Local
public interface ConfigurationService { ... }
Run Code Online (Sandbox Code Playgroud)
@Singleton
public class ConfigurationServiceImpl implements ConfigurationService { ... }
Run Code Online (Sandbox Code Playgroud)
还有一个Eclipselink SessionCustomizer,因为应用程序中的一个持久性单元(Oracle数据库)的模式名称需要以编程方式设置,即可以从之前提到的属性文件进行配置.的SessionCustomizer是在配置persistence.xml和实施包含对一个参考ConfigurationService:
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.0" xmlns="http://java.sun.com/xml/ns/persistence"...
<persistence-unit name="myPU" transaction-type="JTA">
<property name="eclipselink.session.customizer" value="MySessionCustomizer"/>
...
Run Code Online (Sandbox Code Playgroud)
public class MySessionCustomizer implements SessionCustomizer {
@EJB
private ConfigurationService configurationService;
@Override
public void customize(Session session) {
session.getLogin().setTableQualifier(configurationService.getSchemaName());
...
Run Code Online (Sandbox Code Playgroud)
是否有可能以ConfigurationService这种方式注入,以便在SessionCustomizer实例化时可用?上述操作失败,因为ConfigurationService实例仍然为空,即注入尚未发生.此观察对应于服务器的日志条目.似乎依赖注入机制总是在持久性单元 - 因此SessionCustomizer- 被实例化之后开始.我搞砸周围的各种注释(@Startup,@DependsOn(...),...),但无济于事.我的结论是正确的还是有另一种方法让EJB更早实例化并注入?