通常我使用NoResultException来返回一个"空"对象,例如一个空的错误列表或新的BigInteger("0"),如果我没有得到TypedQuery的结果.现在事实证明,这有时不起作用.突然getSingleResult()返回null而不是导致NoResultException,我不明白为什么.看这个例子:
public BigInteger pointsSumByAccountId(long accountId)
{
try
{
TypedQuery<BigInteger> pointsQuery = entityManager.createNamedQuery(Points.SumByAccountId, BigInteger.class);
pointsQuery.setParameter(Points.AccountIdParameter, accountId);
return pointsQuery.getSingleResult();
}
catch (NoResultException e)
{
return new BigInteger("0");
}
}
Run Code Online (Sandbox Code Playgroud)
实体的重要部分......
@NamedQueries({@NamedQuery(name = "Points.sumByAccountId", query = "select sum(p.value) from Points p where p.validFrom <= current_timestamp() and p.validThru >= current_timestamp() and p.account.id = :accountId")})
public class Points
{
private static final long serialVersionUID = -15545239875670390L;
public static final String SumByAccountId = Points.class.getSimpleName() + ".sumByAccountId";
public static final String AccountIdParameter = "accountId";
.
.
. …Run Code Online (Sandbox Code Playgroud) 在私人和公司中,我或我们的开发人员一直在评论我们的代码,但通常没有人确切地知道整个项目的代码是如何协同工作的.当我编写自己的代码并且项目越来越大时,我有时也会遇到这个问题.虽然我写了大量的评论,但是3个月后你不知道究竟是什么,这意味着不同的方法和类如何协同工作.
您如何在公司或私人中解决这个问题(如果只是边际项目开发而没有要求规范).或者您是否总是通过合同文件和要求规范进行如此好的项目开发,而您不必担心这一点?
首先,已经有类似的问题,但这些答案没有帮助.
正如在主题中已经提到的,我想在代码辅助中修改非活动行的颜色(不改变其他区域),因为几乎看不到浅灰色背景上的白色.

"颜色和字体"只包含"内容辅助前景/背景颜色",这只会更改整个代码辅助的前景/背景,而不会更改活动或非活动行的前景/背景.似乎没有这个选项.是否有可能以不同的方式改变它,可能是某种样式表?
我正在使用叠加来标记Google地图上的区域,方法是绘制我从任何来源获得的数万个GeoPoints的形状.这有效,看起来像这样:
@Override
public void draw(android.graphics.Canvas canvas, MapView mapView, boolean shadow) {
super.draw(canvas, mapView, false);
Projection projection = mapView.getProjection();
List<Zone> zones = ApplicationContext.getZones();
path.rewind();
for (Zone zone : zones) {
paint.setDither(true);
paint.setStyle(Style.FILL);
paint.setAlpha(40);
MultiPolygon multiPolygon = zone.getMultiPolygon();
List<Polygon> polygons = multiPolygon.getPolygons();
for (Polygon polygon : polygons) {
for (List<Coordinate> coordinates : polygon.getCoordinates()) {
for (int i = 0; i < coordinates.size(); i++) {
Point p = new Point();
projection.toPixels(new GeoPoint((int)(coordinates.get(i).getLatitude() * 1E6), (int)(coordinates.get(i).getLongitude() * 1E6)), p);
if (i == 0) { …Run Code Online (Sandbox Code Playgroud) 在Maven中,发布过程没有问题.由于我被迫使用带有Gradle的Android Studio,我希望实现与Eclipse和Maven相同的行为.我找到了一些非常好的Maven-like发布插件(https://github.com/researchgate/gradle-release),它几乎按预期工作,但它没有上传发布apk,虽然它正确创建了apk /app/build/outputs/apk和标记我的SVN存储库中的源代码.release文件夹仍为空.我甚至不确定这个插件是否可以做到这一点,因为它没有很好的文档,但我想我需要告诉这个插件要上传什么以及在哪里找到它.只有一个afterReleaseBuild.dependsOn uploadArchives.这是什么意思,我必须覆盖这个uploadArchives方法或Gradle中的这个意思?它似乎是内置的东西,因为如果我在我的脚本中编写并运行,Gradle构建不会抱怨gradlew release.显然插件已经知道存储库并且可以通过ssh连接,否则它无法创建标记,但似乎它不知道要上传什么,发布文件夹保持空白.与此同时,我试图通过许多其他Gradle尝试来解决这个问题,例如使用Maven插件,但后来我遇到SSH证书问题而没有解决方案,即使它有效,也不会是一个好的解决方案,因为我不喜欢不想创建pom.xml文件等,这本来就是一种解决方法.
目标是发布过程应该自动在svn存储库的releases文件夹中创建一个文件夹,该文件夹的名称与当前版本相同(因为它已在tags文件夹中工作,例如1.0.0)并将已发布的apk复制到已经重命名的apk中Gradle的myapp-app-1.0.0-release.apk,因为这是本地输出文件夹中包的名称.
这是我当前的gradle脚本,它可以在输出文件夹中生成release apk但不会将其上传到svn:
apply plugin: 'com.android.application'
apply plugin: 'net.researchgate.release'
def keystorePropertiesFile = rootProject.file("/home/myuser/.android/keystore.properties")
def keystoreProperties = new Properties()
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
android {
lintOptions {
//TODO remove this or set to true
abortOnError false
}
signingConfigs {
myapp_release_config {
keyAlias keystoreProperties['keyAlias']
keyPassword keystoreProperties['keyPassword']
storeFile file(keystoreProperties['storeFile'])
storePassword keystoreProperties['storePassword']
}
}
compileSdkVersion 24
buildToolsVersion "24.0.1"
packagingOptions {
exclude 'META-INF/ASL2.0'
}
defaultConfig {
applicationId "com.mydomain.myapp"
minSdkVersion 9
targetSdkVersion 24
versionCode …Run Code Online (Sandbox Code Playgroud) 我有一个列表List<Payment>,我想将其映射到另一个列表List<PaymentPlan>。这些类型如下所示:
public class Payment {
@XmlElement(name = "Installment")
@JsonProperty("Installment")
private List<Installment> installments = new ArrayList<>();
@XmlElement(name = "OriginalAmount")
@JsonProperty("OriginalAmount")
private BigDecimal originalAmount;
//getters setters, more attributes
}
Run Code Online (Sandbox Code Playgroud)
和....
public class PaymentPlan {
//(Installment in different package)
private List<Installment> installments;
@XmlElement(name = "OriginalAmount")
@JsonProperty("OriginalAmount")
private BigDecimal originalAmount;
//getters setters, more attributes
}
Run Code Online (Sandbox Code Playgroud)
我希望这样的事情正在起作用......
@Mappings({
@Mapping(//other mappings...),
@Mapping(source = "payments", target = "paymentInformation.paymentPlans")
})
ResultResponse originalResponseToResultResponse(OrigResponse originalResponse);
Run Code Online (Sandbox Code Playgroud)
...但我得到:
Can't map property java.util.List<Payment> to java.util.List<PaymentPlan>.
Consider to declare/implement a …Run Code Online (Sandbox Code Playgroud) 不幸的是,Eclipse插件的最新更新丢弃了Inigo并安装了Juno.我花了很多时间让它看起来像以前的版本,但我无法让它设法改变蓝色标签颜色.设置或css的任何想法是什么?

[更新]有更改颜色的设置,但这些设置不会产生任何影响,所以我可以假设它是一个错误吗?

我目前正在设计我的实施策略,以便在应用内结算中进行可能的状态更新(从已购买的状态到已取消的状态等等),这是一个非常令人头疼的问题,并且存在一个混乱:
我在应用程序中获取getPurchases().这给了我INAPP_PURCHASE_DATA包含表6的字段,其中包含以下字段:
autoRenewing,orderId,packageName,productId,purchaseTime,purchaseState,developerPayload,purchaseToken.
我想将一些变量发送到我的服务器(虽然只是buyToken似乎很有用),但有一些我不清楚的事情:
在服务器端,我想不断检查购买是否有效.我计划通过https://developers.google.com/android-publisher/api-ref/purchases/subscriptions/get执行此操作
但是这个请求需要packageName,subscriptionId和token.令牌是purchaseToken从getPurchases() ,但是是subscriptionId中的productId从getPurchases() ?
当您在Google Play中调用用于创建产品列表的手册时,可以在此处的标题中看到此处在步骤4 中将项目一次添加到产品列表中单击"创建被管理产品"或"根据需要创建订阅".你必须在第5步设置productId.
如果productId == subscriptionId,为什么有两个Google Play Developer API请求,一个用于"产品",一个用于"订阅",那么订阅是不是产品呢?看到:
https://developers.google.com/android-publisher/api-ref/purchases/products/get https://developers.google.com/android-publisher/api-ref/purchases/subscriptions/get
第一个请求采用productId,但第二个请求是我没有的subscriptionId,但productId和subscriptionId是相同的.这非常令人困惑.
android in-app-purchase in-app-billing google-play-developer-api
在我的C应用程序中,我有一个解密密钥,用于解密数据库中的集合(用户名/密码).目前,我只是宣布它
char * key = "$$$secretSampleDecryptionKey$$$";
Run Code Online (Sandbox Code Playgroud)
在该行之后不久,我准备SQL语句,然后从DB中进行选择.我的问题是,如果有人要调试我编译的应用程序或解组它,他们真的会看到密钥吗?我该怎么做才能将它们隐藏起来?
编辑:
正如Mark和Aaron指出的那样,我可以简单地使用Linux/Unix字符串命令
strings nameOfApplication
Run Code Online (Sandbox Code Playgroud)
打印出我的应用程序中的所有字符串,包括"秘密"密钥.
编辑2:
该应用程序在我的服务器上运行,数据库存储加密的敏感客户数据.我以为我是安全的,因为没有文本文件中的密钥供所有人阅读,而是编译它.
我将业务对象映射到实体,并且在某些情况下实体的结构与业务对象不同。
我将userCategories它们作为字符串存储在业务对象中RecipeBo,因为 BO 不需要了解有关实体的内部结构的任何信息。这些字符串需要映射到Recipe和的关系RecipeUserCategoryRel,除此之外,另一个字段userId也RecipeBo需要映射到其中RecipeUserCategoryRel。
我的方法(有效)是创建一个包装器并手动创建关系,但这看起来像是修补:
public class BoMapper
{
private final static ModelMapper modelMapper = new ModelMapper();
static
{
modelMapper.addMappings(new IngredientMap());
}
public static void map(Object from, Object to)
{
modelMapper.map(from, to);
if (from instanceof RecipeBo && to instanceof Recipe)
{
RecipeBo recipeBo = (RecipeBo)from;
List<String> userCategories = recipeBo.getUserCategories();
List<RecipeUserCategoryRel> recipeUserCategoryRels = new ArrayList<>();
for (String userCategory : userCategories)
{
recipeUserCategoryRels.add(new RecipeUserCategoryRel(userCategory, recipeBo.getUserId()));
}
Recipe recipe …Run Code Online (Sandbox Code Playgroud) android ×2
eclipse ×2
java ×2
bitmap ×1
c ×1
code-assist ×1
colors ×1
comments ×1
cryptography ×1
google-maps ×1
gradle ×1
hql ×1
jpa ×1
jpa-2.0 ×1
mapping ×1
mapstruct ×1
modelmapper ×1
overlay ×1
project ×1
tabs ×1
ubuntu ×1
ubuntu-10.10 ×1
ubuntu-12.04 ×1