小编ren*_*ena的帖子

Firebase按ID获取用户

有没有办法根据其UID获取用户信息(如电子邮件,图片)?

我的意思是不是当前登录的用户,而是任何其他用户.

firebase firebase-authentication

6
推荐指数
1
解决办法
2万
查看次数

Spring Tool Suite:@Configuration 类可能不是最终的。删除最终修饰符以继续

由于以下原因,我无法启动 spring boot kotlin 应用程序:

org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: @Configuration class 'TestApplication' may not be final. Remove the final modifier to continue.
Run Code Online (Sandbox Code Playgroud)

我知道 @configuration 和 @bean 类不能是最终的,所以我在我的 pom 文件中添加了 allopen 插件:

<build>
    <sourceDirectory>${project.basedir}/src/main/kotlin</sourceDirectory>
    <testSourceDirectory>${project.basedir}/src/test/kotlin</testSourceDirectory>
    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
        </plugin>
        <plugin>
            <groupId>org.jetbrains.kotlin</groupId>
            <artifactId>kotlin-maven-plugin</artifactId>
            <configuration>
                <args>
                    <arg>-Xjsr305=strict</arg>
                </args>
                <compilerPlugins>
                    <plugin>spring</plugin>
                </compilerPlugins>
            </configuration>
            <dependencies>
                <dependency>
                    <groupId>org.jetbrains.kotlin</groupId>
                    <artifactId>kotlin-maven-allopen</artifactId>
                    <version>${kotlin.version}</version>
                </dependency>
            </dependencies>
        </plugin>
    </plugins>
</build>
Run Code Online (Sandbox Code Playgroud)

如果我打包我的应用程序并运行它(java -jar)它可以工作,但是当我尝试从 STS 启动它时它不起作用。

Kotlin 版本:1.2.71 Kotlin eclipse 插件:0.8.13 STS:3.9.5

eclipse kotlin

6
推荐指数
1
解决办法
6857
查看次数

spring data jpa不必要的左连接

我有以下型号:

在此输入图像描述

我希望得到所有Institutions(Intituciones)指定sectorId.

tbInstitucion模型中,我与tbSector以下关系:

 @ManyToOne(fetch=FetchType.LAZY)
 @JoinColumn(name="`sectorId`")
 private Sector sector;
Run Code Online (Sandbox Code Playgroud)

有没有办法获得如下查询:

select * 
from tbInstitucion 
where sectorId = ?
Run Code Online (Sandbox Code Playgroud)

我尝试过: findBySector(Sector sector)

但有了这个,我需要一个额外的查询来查找扇区,findBySector并生成以下查询:

select
        generatedAlias0.institucionId,
        generatedAlias0.institucionNombre 
    from
        Institucion as generatedAlias0 
    left join
        generatedAlias0.sector as generatedAlias1 
    where
        generatedAlias1=:param0
Run Code Online (Sandbox Code Playgroud)

试过另一个:

findBySector_sectorId
Run Code Online (Sandbox Code Playgroud)

它也会生成上述查询.

形成如下查询不会更好:

select * 
from tbInstitucion 
where sectorId = ?
Run Code Online (Sandbox Code Playgroud)

有没有办法获得上述查询?为什么JPA会产生左连接?

java postgresql spring jpa spring-data-jpa

5
推荐指数
2
解决办法
3021
查看次数

JPA:冗余保存反模式

所以我有这个方法:

@Transactional
public void savePostTitle(Long postId, String title) {
    Post post = postRepository.findOne(postId);
    post.setTitle(title);
}
Run Code Online (Sandbox Code Playgroud)

根据这篇文章

save 方法没有任何用处。即使我们删除它,Hibernate 仍然会发出 UPDATE 语句,因为实体是被管理的,只要当前运行的 EntityManager 处于打开状态,任何状态更改都会传播。

并且确实发出了更新语句,但是如果我在没有@Transactional注释的情况下运行该方法:

public void savePostTitle(Long postId, String title) {
        Post post = postRepository.findOne(postId);
        post.setTitle(title);
    }
Run Code Online (Sandbox Code Playgroud)

Hibernate 不会发出更新语句,因此必须postRepository.save(post);显式调用。

@Transactional在这个特定场景中使用与不使用有什么区别?

java hibernate jpa spring-data-jpa

5
推荐指数
1
解决办法
839
查看次数

PowerShell 等待应用程序启动

我有以下脚本来启动应用程序:

add-type -AssemblyName microsoft.VisualBasic
add-type -AssemblyName System.Windows.Forms
$args = "arguments"
$proc = Start-Process -PassThru "path" -ArgumentList $args
start-sleep -Seconds 5
[Microsoft.VisualBasic.Interaction]::AppActivate($proc.Id)
[System.Windows.Forms.SendKeys]::SendWait("~")
Run Code Online (Sandbox Code Playgroud)

我使用这个脚本来启动几个需要用户交互才能启动的 Windows 窗体应用程序(即按下启动按钮)。到目前为止,我一直在让脚本休眠 5 秒钟以允许应用程序启动。我尝试在具有不同处理能力的各种计算机上运行此脚本,但并没有在所有计算机上运行,​​有些计算机启动应用程序比其他计算机慢,当应用程序启动应用程序超过 5 秒时脚本失败,因为AppActivate 找不到 PID。我不想为每台计算机尝试不同的睡眠时间,因为我必须在启动时在 100 多台计算机上运行此脚本。

我想知道是否有办法以事件驱动的方式等待应用程序启动。

更新:

WaitForInputIdle 不适用于我尝试启动的所有应用程序。它立即返回(成功是因为它返回 true)并且 AppActive 方法抛出异常。

powershell

3
推荐指数
1
解决办法
3551
查看次数

Firebase facebook登录照片网址签名已过期

我在我的APP中使用Firebase(angularfire)和Facebook登录来验证我的用户.但是今天我意识到配置文件图片网址已过期,但Firebase SDK没有刷新它.

有没有办法解决这个问题,还是应该使用Facebook API请求图像?

facebook-login firebase firebase-authentication

3
推荐指数
2
解决办法
2035
查看次数

JPA ManyToMany 插入重复值

我有以下模型:

@Entity
@Table(name="`tbUser`")
public class User {
    @Id
    @SequenceGenerator(name="tbuser_id_seq",
    sequenceName="tbuser_id_seq",
    allocationSize=1)
    @Column(name="`userId`")
    @GeneratedValue
    private Long id;
    @Column(name="username")
    private String username;
    @Column(name="password")
    private String password;
    @Column(name="nombres")
    private String firstName;
    @Column(name="apellidos")
    private String lastName;
    @Column(name="email")
    private String email;
    @Column(name="`avatarUrl`")
    private String avatarUrl;
    @ManyToMany(fetch=FetchType.EAGER, cascade=CascadeType.MERGE)
    @JoinTable(name="`tbUserRole`", 
    joinColumns=@JoinColumn(name="`userId`",referencedColumnName="`userId`"), 
    inverseJoinColumns=@JoinColumn(name="`roleId`",referencedColumnName="`roleId`"))
    private List<Role> roles = new ArrayList<>();
...

@Entity
@Table(name="`tbRole`")
public class Role {
    @Id
    @Column(name="`roleId`")
    @GeneratedValue
    private Long id;
    @Column(name="name")
    String name;
    @ManyToMany(mappedBy="roles")
    private List<User> users = new ArrayList<>();
...
Run Code Online (Sandbox Code Playgroud)

映射到下表:

急诊室 我尝试通过以下两种方式插入具有现有角色的用户:

user.getRoles().add(role) and repository.save(new …
Run Code Online (Sandbox Code Playgroud)

postgresql spring jpa

1
推荐指数
1
解决办法
2946
查看次数