Eclipse警告我正在使用不推荐使用的方法:
eventDay = event.getEvent_s_date().getDate();
Run Code Online (Sandbox Code Playgroud)
所以我把它改写成了
eventDay = DateUtil.toCalendar(event.getEvent_s_date()).get(Calendar.DATE);
Run Code Online (Sandbox Code Playgroud)
它似乎工作,但它看起来很难看.我的问题是我是否以最好的方式重构了这个?如果没有,你会如何重构?我需要存储在bean中的日期的日期编号.
我最终在我的DateUtils中添加了一个方法来清理它
eventDay = DateUtil.getIntDate(event.getEvent_s_date());
public static int getIntDate(Date date) {
return DateUtil.toCalendar(date).get(Calendar.DATE);
}
Run Code Online (Sandbox Code Playgroud) 我有以下实体:
@Entity
public class Shirt implements Serializable {
@Id
@Size(max=9)
private String id;
@ElementCollection
@CollectionTable(name="SHIRT_COLORS")
@Column(name="color")
private List<String> colors = new ArrayList<String>();
...
Run Code Online (Sandbox Code Playgroud)
我将hibernate设置为autocreate时创建的集合表是
SHIRT_COLORS
shirt_id
color
Run Code Online (Sandbox Code Playgroud)
如何注释我的实体,以便连接列不是实体和pk的串联,以便创建的表是:
SHIRT_COLORS
id
color
Run Code Online (Sandbox Code Playgroud)
我试过@JoinColumn但是没用.实际上,生产中的SHIRT_COLORS表在应用程序之外进行管理,并且已经定义了列名.
不确定这是否可行,但尝试WorkflowInstancePlayer player
根据两个其他实体映射WorkActionClass
以及WorkflowInstance
下面的实体映射哪些相关.
public class Action implements Serializable {
@Id
private Long action_id;
@ManyToOne
@JoinColumn(name = "work_action_class_id", referencedColumnName = "work_action_class_id")
private WorkActionClass workActionClass;
@ManyToOne
@JoinColumn(name = "workflow_instance_id", referencedColumnName = "workflow_instance_id")
private WorkflowInstance workflowInstance;
UPDATE: How can I map to a WorkflowInstancePlayer player?????
@ManyToOne
@JoinColumns( {
@JoinColumn(name = "workflow_instance_id", referencedColumnName = "workflow_instance_id", insertable = false, updatable = false),
@JoinColumn(name = "workActionClass.role_class_id", referencedColumnName = "role_class_id", insertable = false, updatable = false)
})
private WorkflowInstancePlayer player;
Run Code Online (Sandbox Code Playgroud)
workflowInstancePlayer是基于workflow_instance_id …
我们使用是造成问题的一个伟大的交易,因为用户没有点击一个第三方应用Register
点击之前,按钮Launch
按钮,或者,如果他们点击Register
第一个,这方面的细节页与Register
和Launch
按钮刷新并进入他们的投资组合.然后他们必须在他们的protfolio列表中重新找到该项目.
我认为第三方应用程序是.NET,并且正在使用knockout.js并且不允许嵌入到Frame中.
有哪些选项可以为用户提供指导,或者理想地使这个过程不那么痛苦?
我希望提供一个内部网页,只需按一下按钮即可发送这两个内容Request
和Launch
动作.我发布了一个早期的问题Knockout数据绑定点击但无法得到一些工作.
在SO上似乎有一堆类似的问题,但我不确定这些问题/答案是否用于自动按钮点击自包含应用程序,因为我想从第三方应用程序外部进行操作(我是否可以访问他们的观点模型?).此应用程序可防止将其嵌入框架中.
目前我有一个内部网站链接,可以并排打开两个浏览器窗口.一个人去指示第三方和第二个窗口.这没关系,但我们发现人们不想阅读.我真的想点击一下按钮,或者至少能够从内部网页一次发送一个请求.或者,如果可能的话,或者将兜风类型的指导覆盖到他们的网站上.
这是第三方按钮代码
<a class="btn btn-large btn-blue" href="javascript:void(0);"
data-bind="click: $root.clickAction.bind($data, ActionType)">
<span data-bind="text: Title">Register</span></a>
Run Code Online (Sandbox Code Playgroud) 我正在计算按月分组的SUM
Query q = entityManager.createNativeQuery(qlString);
q.setParameter("program", program);
@SuppressWarnings("unchecked")
List<Long> resultList = (List<Long>) q.getResultList();
long tend = System.currentTimeMillis();
Run Code Online (Sandbox Code Playgroud)
当我传入两个resultsLists(已关闭:Closed项目的结果列表,closedLate:结果列表项目已关闭)到计算百分比的方法时,我得到
javax.servlet.ServletException: java.lang.ClassCastException: java.math.BigDecimal cannot be cast to java.lang.Long
Run Code Online (Sandbox Code Playgroud)
.
private List<Long> computeOTR(List<Long> closed, List<Long> closedLate) {
List<Long> monthlyOTR = new ArrayList<Long>();
long numerator;
Long denominator;
for (int i = 0; i <11; i++) {
numerator = closed.get(i) - closedLate.get(i); <----java.lang.ClassCastException
denominator = closed.get(i);
long percentage = (int)(numerator * 100.0 / denominator + 0.5);
monthlyOTR.add(i, percentage);
}
return monthlyOTR;
Run Code Online (Sandbox Code Playgroud)
}
在Eclipse中,调试模式关闭显示为BigDecimal.为什么这是我的decalre
List<Long> resultList …
我正在尝试使用现有项目创建一个原型,mvn archetype:create-from-project
但我得到了
Could not transfer artifact org.apache.maven.archetype:archetype-packaging:pom:3.0.0
from/to central (https://repo.maven.apache.org/maven2):
sun.security.validator.ValidatorException: PKIX path building failed:
sun.security.provider.certpath.SunCertPathBuilderException:
unable to find valid certification path to requested target
Run Code Online (Sandbox Code Playgroud)
我在防火墙后面所以我按照这篇文章/sf/answers/1813908771/ 然后执行:
$ mvn archetype:create-from-project -Djavax.net.ssl.keyStore=trustCARoot.jks
-Djavax.net.ssl.keyStorePassword=password
-Djavax.net.ssl.keyStoreType=JKS
-Djavax.net.ssl.trustStore=trustCARoot.jks
-Djavax.net.ssl.trustStorePassword=password
-Djavax.net.ssl.trustStoreType=JKS
Run Code Online (Sandbox Code Playgroud)
我仍然得到相同的PKIX路径构建失败,但只是为了 archetype-packaging
[INFO] Setting default groupId: com.domain.rozycki
[INFO] Setting default artifactId: SkillsApp
[INFO] Setting default version: 0.0.1-SNAPSHOT
[INFO] Setting default package: com.domain.skillsapp
[INFO] Scanning for projects...
[INFO] Downloading: https://repo.maven.apache.org/maven2/org/apache/maven/archetype/archetype-packaging/3.0.0/archetype-packaging-3.0.0.pom
[ERROR] [ERROR] Some problems were encountered while processing the POMs:
[ERROR] Unresolveable …
Run Code Online (Sandbox Code Playgroud) 我尝试使用Sun Java PetStore演示.
在CatalogFacade类中,有以下注释:
@PersistenceUnit(unitName="myPetStorePU")
private EntityManagerFactory emf;
Run Code Online (Sandbox Code Playgroud)
在CatalogFacade Sun的所有方法中都有:
EntityManager em = emf.createEntityManager();
Run Code Online (Sandbox Code Playgroud)
但是在尝试createEntityManager时,我得到emf的空指针异常.但是......如果我在该行上方添加以下行
EntityManagerFactory emf = javax.persistence.Persistence.createEntityManagerFactory("myPetStorePU");
EntityManager em = emf.createEntityManager();
Run Code Online (Sandbox Code Playgroud)
然后emf成功创建,持久性单元myPetStorePU也成功连接到数据库.所以它看起来像persistence.xml语法和它的位置是正确的.我想理解为什么注释不起作用,因为我认为只有使用注释而不是在每个方法中添加createEntityManagerFactory行是有原因的.
我的src/META-INF/persistence.xml文件如下所示:
<persistence-unit name="myPetStorePU">
<description>Petstore Persistence Unit</description>
<provider>oracle.toplink.essentials.ejb.cmp3.EntityManagerFactoryProvider</provider>
<class>com.sun.javaee.blueprints.petstore.model.Tag</class>
<class>com.sun.javaee.blueprints.petstore.model.SellerContactInfo</class>
<class>com.sun.javaee.blueprints.petstore.model.Product</class>
<class>com.sun.javaee.blueprints.petstore.model.Item</class>
<class>com.sun.javaee.blueprints.petstore.model.Category</class>
<class>com.sun.javaee.blueprints.petstore.model.Address</class>
<class>com.sun.javaee.blueprints.petstore.model.ZipLocation</class>
<properties>
<property name="toplink.jdbc.driver" value="oracle.jdbc.driver.OracleDriver"/>
<property name="toplink.jdbc.url" value="jdbc:oracle:thin:@#############"/>
<property name="toplink.jdbc.user" value="####"/>
<property name="toplink.jdbc.password" value="#####"/>
<property name="toplink.logging.level" value="INFO"/>
</properties>
</persistence-unit>
Run Code Online (Sandbox Code Playgroud)
编辑:CatalogFacade位于petstore.model包中并实现ServletContextListener
<listener>
<listener-class>com.sun.javaee.blueprints.petstore.model.CatalogFacade</listener-class>
</listener>
Run Code Online (Sandbox Code Playgroud)
在index.jsp中Sun有以下内容:
<%
CatalogFacade cf = (CatalogFacade)config.getServletContext().getAttribute("CatalogFacade");
List<Tag> tags=cf.getTagsInChunk(0, 12);
%>
public List<Tag> getTagsInChunk(int start, int chunkSize) {
//The next line …
Run Code Online (Sandbox Code Playgroud) ORIGINAL JSP(WorkItem.jsp)
<c:forEach var="actionItem" items="${workItem.work_action_list}">
<c:if test="${actionItem.workActionClass.work_action_type_id == '1'}" >
<%@ include file="inc_done_button.jsp" %>
</c:if>
<c:if test="${actionItem.workActionClass.work_action_type_id == '2'}" >
<c:set var="actionItem" value="${actionItem}" scope="request" />
<c:set var="checklist" value="${actionItem.meat}" scope="request" />
<jsp:include page="inc_dynamic_checklist_v.jsp" flush="true" />
</c:if>
etc...
</c:forEach>
Run Code Online (Sandbox Code Playgroud)
原始Java
for (ListIterator<WorkflowInstanceWorkItemAction> actionIter = wfiwi.getWork_action_list().listIterator(); actionIter.hasNext();) {
if ("2".equals(work_action_type_id)) {
ChecklistInstanceForm ciForm = new ChecklistInstanceForm(this, authenticatedUser);
ChecklistInstance ci = null;
ci = (ChecklistInstance) ciForm.getChkLstInstanceByWfiWiaOwner(wfiWorkItemAction, authenticatedUser);
// Get the meat details for this action and inject it into the object
wfiWorkItemAction.setMeat(ci);
} …
Run Code Online (Sandbox Code Playgroud) 我有以下唯一约束
dup_Checklist_QNum UNIQUE (QUESTION_NO, IS_ACTIVE)
Run Code Online (Sandbox Code Playgroud)
我正在尝试阻止两个在激活时具有相同问题编号的问题(IS_ACTIVE值= 1).
在我不得不第二次提出问题之前,一切似乎都很好.
QUESTION_NO=1, TEXT="Have you..", REV=1, IS_ACTIVE=0
QUESTION_NO=1, TEXT="Have you..", REV=2, IS_ACTIVE=0 <-- This should be ok but constraint was violated
QUESTION_NO=1, TEXT="Have you..", REV=3, IS_ACTIVE=1
QUESTION_NO=1, TEXT="Have you..", REV=3, IS_ACTIVE=1 <-- This should be throw constraint exception
Run Code Online (Sandbox Code Playgroud)
我需要约束仅在IS_ACTIVE = 1时应用
Eclipse编译并运行这个jsp很好但是当我部署到Sun One 6.1时,我得到"Code for too try for try {"
我正在尝试在执行聚合摘要时循环遍历bean列表.有关如何重构它以使其在我们过时的服务器上工作的任何建议吗?
<c:set var="ahJan" value="20" scope="request" />
<c:set var="ahTot" value="246" scope="request" />
<table border="0" width="95%" cellspacing="0" cellpadding="0" class="tableBlackBorder">
<tr>
<td>
<table width="100%" border="0" cellpadding="1" class="tableInternalBorder" id="sortable">
<tr>
<td class="tl">Source</td>
<td class="tl">Program</td>
<td class="tl">Project</td>
<td class="tl">Contract</td>
<td class="tl">Line Code</td>
<td class="tl">Jan</td>
<td class="tl">Total</td>
</tr>
<c:set var="prevProgram" value="" scope="request" />
<c:set var="prevProject" value="" scope="request" />
<c:set var="prevContract" value="" scope="request" />
<c:set var="prevLinecode" value="" scope="request" />
<c:set var="prevBusArea" value="" scope="request" />
<c:set var="ctc_totSub" value="" scope="request" …
Run Code Online (Sandbox Code Playgroud) java ×6
jpa ×4
hibernate ×2
jsp ×2
annotations ×1
certificate ×1
constraints ×1
date ×1
facelets ×1
html ×1
javascript ×1
jsf ×1
knockout.js ×1
maven ×1
oracle ×1
orm ×1
persistence ×1
refactoring ×1
sql ×1
ssl ×1
zurb-joyride ×1