首页 > 解决方案 > 如何通过本机反应在单对多关系中获得实体的一侧

问题描述

我使用 jhipster 创建应用程序并启动 cli。应用程序是用户的任务管理器。每个用户都有多个任务。但任务只能有一个用户。当我单击查看任务的详细信息时,它会显示 ID、名称和截止日期,但不会显示应该拥有该任务的用户名。我是 React Native 的新手。我使用 java spring boot 后端。

这是我在 task_detail.js 中的渲染

<ScrollView style={styles.container} testID="taskDetailScrollView">
   <Text style={styles.text}>ID: {this.props.task.id}</Text>
   <Text testID="task" style={styles.text}>Task: {this.props.task.task}</Text>
   <Text testID="deadline" style={styles.text}>Deadline: {String(this.props.task.deadline)}</Text>
   <Text style={styles.text}>User: {this.props.task.user_id}</Text>
   <RoundedButton text="Edit" onPress={taskEntityEditScreen.bind(this, { entityId: this.props.task.id })} />
   <RoundedButton text="Delete" onPress={this.confirmDelete} />
</ScrollView>

这是我的构造函数

constructor(props) {
   super(props)
   Navigation.events().bindComponent(this)
   this.props.getTask(this.props.data.entityId)
}

我在任务表中有 user_id 的外键。我需要从该外键 user_id 获取用户名。

标签: spring-bootreact-nativejhipster

解决方案


推荐阅读