在我们的项目中,我们有不同类别的不同用户类型.我们有一个BaseEntity类作为@MappedSuperclass.当我们尝试使用带有InheritanceType.JOINED的用户类时,hibernate会创建一个我们认为错误的sql.
基本实体:
@MappedSuperclass
public abstract class BaseEntity implements java.io.Serializable {
private Integer id;
private Date createdDate = new Date();
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
@Temporal(TemporalType.TIMESTAMP)
@Column(name = "CREATED_DATE", nullable = true)
public Date getCreatedDate() {
return createdDate;
}
public void setCreatedDate(Date createdDate) {
this.createdDate = createdDate;
}
}
Run Code Online (Sandbox Code Playgroud)
基本用户
@Entity
@Table(name = "BASE_USER")
@Inheritance(strategy = InheritanceType.JOINED)
@AttributeOverride(name = "id", column = @Column(name = "ID", nullable = false, insertable = …
Run Code Online (Sandbox Code Playgroud) 我想使用以下代码将数据插入表中
public User registerUser(String usr, String pwd) {
u=em.find(User.class,usr);
if(u!=null)
{
return null;
}
String query1 = "insert into users values('" + usr + "','" + pwd +"')";
Query q = em.createQuery(query1);
u=em.find(User.class,usr);
return u;
Run Code Online (Sandbox Code Playgroud)
}
这里'u
'是User
阶级的对象,em
是EntityManager
.
我得到以下异常:
用于servlet操作的Servlet.service()抛出异常org.hibernate.hql.ast.QuerySyntaxException:期待OPEN,在第1行第19列附近找到'values'[插入用户值('pawan','am')]
我有一个方法,用于ServiceLoader
使用资源加载服务.
public List<String> getContextData(int Id)
{
List<String> list = new ArrayList<String>();
ServiceLoader<ContextPlugin> serviceLoader = ServiceLoader.load(ContextPlugin.class);
for (Iterator<ContextPlugin> iterator = serviceLoader.iterator(); iterator.hasNext();)
{
list .addAll(iterator.next().getContextData(Id));
}
return list;
}
Run Code Online (Sandbox Code Playgroud)
我应该如何使用Junit对上述方法进行单元测试?
在这个脚本中,cars [i]被用作条件如何在程序进入阵列中的第4个变量后,程序如何识别条件的天气true
或者false
程序是否正确停止?
所以问题是:程序如何识别条件以及如何将汽车[i]作为一种条件.
var cars = ["BMW", "Volvo", "Saab", "Ford"];
var i = 0;
var text = "";
for (;cars[i];) {
text += cars[i] + "<br>";
i++;
}
Run Code Online (Sandbox Code Playgroud) 仍然抓住Ajax,所以我请耐心等待.我试图在javascript的帮助下使用ajax调用从javascript中运行一个php文件.我不需要GET/POST任何数据,我只是想要执行PHP代码并将消息'hello world'记录到控制台(我打算在带有onclick()函数的按钮中使用它).唯一记录的是"成功"消息.我希望PHP代码在不离开当前页面的情况下执行,但我想我可能会错过AJAX的工作原理.或者也许有更好的方法来实现这一目标.谢谢你的帮助.
PS:通过使用Safari的Web开发人员工具,我可以看到资源"ajax.php"正在作为XHR加载.
调用ajax.php的索引文件的内容是:
<script>
$.ajax({
url : 'action/ajax.php',
type : 'POST',
success : function (result) {
console.log ('success');
},
error : function () {
console.log ('error');
}
});
</script>
Run Code Online (Sandbox Code Playgroud)
ajax.php的内容是:
<?php
echo '<script>console.log("hello world");</script>';
?>
Run Code Online (Sandbox Code Playgroud)